[#BloombergLP-bsls-BslSourceNameParserUtil-getComponentName]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bsls.adoc[bsls]::xref:BloombergLP/bsls/BslSourceNameParserUtil.adoc[BslSourceNameParserUtil]::getComponentName
:relfileprefix: ../../../
:mrdocs:

Parse a Lakos&hyphen;style source file name and return its component name&period;

== Synopsis

Declared in `&lt;bsls&lowbar;bslsourcenameparserutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
getComponentName(
    char const** componentNamePtr,
    size&lowbar;t* componentNameLength,
    char const* sourceName,
    unsigned int* type&lowbar;p = 0);
----

== Description

Parse the specified Lakos&hyphen;style `sourceName` source file name with optional path portion to find the component name part&period; Return zero on success and a non&hyphen;zero value if parsing failed&period; 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&period; Optionally specify `type&lowbar;p`&period; When `type&lowbar;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&period;

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

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

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

== Return Value

0 on success, or a non&hyphen;zero value if parsing failed

== Parameters

[cols="1,4"]
|===
| Name| Description
| *componentNamePtr*
| address of the pointer set to the component name on success
| *componentNameLength*
| address of the length set to the component name length on success
| *sourceName*
| Lakos&hyphen;style source file name, optionally with a path
| *type&lowbar;p*
| optional address of a bit field describing the source type&semi; when non&hyphen;null, bits are set according to `SourceTypes`
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
