BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsls::BslSourceNameParserUtil Struct Reference

#include <bsls_bslsourcenameparserutil.h>

Public Types

enum  SourceTypes {
  k_MASK_KIND = 0x3 , k_MASK_TEST = 0x2 , k_HEADER = 0x0 , k_IMPL = 0x1 ,
  k_TTEST = 0x2 , k_GTEST = 0x3 , k_IS_TEST_XTEMPLATE = 0x4 , k_IS_MULTIFILE_TEST = 0x8 ,
  k_IS_SUBORDINATE_TEST = 0x10 , k_IS_CPP03_GENERATED = 0x20
}
 

Static Public Member Functions

static int getComponentName (const char **componentNamePtr, size_t *componentNameLength, const char *sourceName, unsigned *type_p=0)
 
static const char * errorMessage (int errorCode)
 

Detailed Description

This struct provides a namespace for static utility functions that parse source file names (as may be reported by the __FILE__ macro), including Lakos-style component source and test driver names.

Member Enumeration Documentation

◆ SourceTypes

Enumerator
k_MASK_KIND 
k_MASK_TEST 
k_HEADER 
k_IMPL 
k_TTEST 
k_GTEST 
k_IS_TEST_XTEMPLATE 
k_IS_MULTIFILE_TEST 
k_IS_SUBORDINATE_TEST 
k_IS_CPP03_GENERATED 

Member Function Documentation

◆ errorMessage()

static const char * bsls::BslSourceNameParserUtil::errorMessage ( int  errorCode)
static

Return a static, brief English error message that describes the specified negative parsing errorCode. The behavior is undefined unless errorCode < 0 and was returned by one of the parsing methods (of this utility) that states in its contract to use this method to get the description of an error code.

◆ getComponentName()

static int bsls::BslSourceNameParserUtil::getComponentName ( const char **  componentNamePtr,
size_t *  componentNameLength,
const char *  sourceName,
unsigned *  type_p = 0 
)
static

Parse the specified Lakos-style sourceName source file name with optional path portion to find the component name part. Return zero on success and a non-zero value if parsing failed. In case of success, fill the specified componentNamePtr with a pointer to the first character, and the specified componentNameLength with the number of character of the component name found. Optionally specify type_p. When type_p is not 0 set the bits of the pointed unsigned, according to SourceTypes, that describe the type of the source file that was parsed.

This function does not validate its input, it assumes that it is a valid Lakos-style component source or test driver file name, or one of the special names defined by John Lakos: Large Scale C++ Design (application, adapter, etc). If SourceName is not as such, the function may return a non-zero error value, or it may report success with its output is unspecified.

Subordinate test component sources are special, as they should not contain code, only their test drivers. The component name reported for subordinate test drivers is the main component name.

Use the errorMessage function (in this utility) to get a static, brief English textual description of a negative return value.


The documentation for this struct was generated from the following file: