Quick Links:

bal | bbl | bdl | bsl

Public Types | Static Public Member Functions

bsls::BslSourceNameParserUtil Struct Reference

#include <bsls_bslsourcenameparserutil.h>

List of all members.

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_MULTIFILE_TEST = 0x4, k_IS_SUBORDINATE_TEST = 0x8,
  k_IS_CPP03_GENERATED = 0x10
}

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.

See Component bsls_bslsourcenameparserutil


Member Enumeration Documentation

Bit masks and constants that describe the meaning of the type_p parameter of getComponentName below. Only some bits of the lowest significant word are used at the moment: .. 7 6 5 4 3 2 10 |r|r|r|3|S|M|KK|

K - two bits describing the extension (kind)

M - a bit that is set only the file is a test driver source file, and it is a multi-file test driver that has a "segment" of (normally) decimal digits, e.g., "abcx_name.14.g.cpp".

S - a bit that is set if the file belongs to a subordinate test driver, a file that has "_test", followed by non-underscore characters (except if it is also a generated simulation file for C++03, see below)

3 - a bit that is set if the file name is a generated simulation file for C++03 (simulates some C++11 features such as variadic templates up to a certain number of parameters etc)

r - all other bits are reserved for future use .. For example "abcx_name_testq_cpp03.g.cpp" will be

Enumerator:
k_MASK_KIND 
k_MASK_TEST 
k_HEADER 

.h

k_IMPL 

.cpp

k_TTEST 

.t.cpp -- traditional test driver

k_GTEST 

.g.cpp -- Google test test driver

k_IS_MULTIFILE_TEST 

"[^a-z0-9]+.(t.cpp|g.cpp)"

k_IS_SUBORDINATE_TEST 

"_test[^a-z0-9]*.(h|cpp|t.cpp|g.cpp)"

k_IS_CPP03_GENERATED 

"_cpp03" at the very end, before exts


Member Function Documentation

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.

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.


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