43#if defined __cplusplus
89 for( spectralID =
channelID->spectralIDs; spectralID != NULL; spectralID = next ) {
90 next = spectralID->
next;
101 return( _tpi_channelID_parse2( smr, str, str, 0, EOP ) );
113 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"Empty channel string to parse for '%s'", origStr );
121 priorSpectral->
next = spectralID;
122 priorSpectral = spectralID;
124 if( **EOP == 0 )
break;
125 if( isDecayChannel && ( **EOP ==
')' ) )
break;
127 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"Missing '+' (or maybe ')') in channelID at '%s' of '%s'", *EOP, origStr );
148 char *sans[] = { (
char*)
"revision", NULL };
159 for( spectralID =
channelID->spectralIDs; spectralID != NULL; spectralID = spectralID->
next ) {
161 if( spectralID->
next != NULL ) {
162 if( (
gString_addTo( smr, gStr,
" + " ) ) != 0 )
return( 1 );
177 return( spectralID );
193 if( spectralID != NULL ) {
206 if( spectralID->
name != NULL ) free( spectralID->
name );
207 for( qualifier = spectralID->
qualifiers; qualifier != NULL; qualifier = next ) {
208 next = qualifier->
next;
220 return( _tpi_spectralID_parse2( smr, str, str, EOP ) );
227 int breakup = 0, i1, i2, m;
237 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"Empty spectralID string to parse for '%s'", origStr );
245 if( !isalpha( **EOP ) ) {
246 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"Invalid spectralID name '%s' in '%s'", *EOP, origStr );
249 for( s = *EOP, i1 = 0; ( isalnum( **EOP ) ) || ( **EOP ==
'_' ); (*EOP)++ ) i1++;
257 while( **EOP == bOrC ) {
261 if( !isalpha( **EOP ) ) {
262 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"Invalid qualifier name '%s' in '%s'", *EOP, origStr );
266 for( s = *EOP, i1 = 0; ( isalnum( **EOP ) ) || ( **EOP ==
'_' ); (*EOP)++ ) i1++;
270 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"Missing ':' in qualifier defintion at '%s' in '%s'", *EOP, origStr );
277 if( ( **EOP !=
'"' ) && ( **EOP !=
'\'' ) ) {
278 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"Missing start quote in qualifier defintion at '%s' in '%s'", *EOP, origStr );
284 for( q = *EOP, i2 = 0; ( **EOP != c ) && ( **EOP != 0 ); (*EOP)++ ) i2++;
286 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"Missing end quote in qualifier defintion at '%s' in '%s'", *EOP, origStr );
297 qualifier->
next = NULL;
298 qualifier->
name = (
char *) &(qualifier[1]);
299 qualifier->
value = &(qualifier->
name[i1+1]);
300 strncpy( qualifier->
name, s, i1 );
301 qualifier->
name[i1] = 0;
302 strncpy( qualifier->
value, q, i2 );
303 qualifier->
value[i2] = 0;
305 if( strcmp( qualifier->
name,
"revision" ) == 0 ) {
307 else if( strcmp( qualifier->
name,
"multiplicity" ) == 0 ) {
309 else if( strcmp( qualifier->
name,
"level" ) == 0 ) {
312 priorQualifier->
next = qualifier;
313 priorQualifier = qualifier;
316 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"Missing ']' for qualifier at '%s' in '%s'", *EOP, origStr );
325 if( spectralID->
levelStr != NULL ) {
326 d = strtod( spectralID->
levelStr, &e );
327 if( ( *e == 0 ) && ( e != spectralID->
levelStr ) ) spectralID->
level = d;
332 if( ( **EOP !=
'-' ) || ( (*EOP)[1] !=
'>' ) ) {
333 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"Missing '->' for breakup at '%s' in '%s'", *EOP, origStr );
338 if( (spectralID->
decayChannel = _tpi_channelID_parse2( smr, *EOP, origStr, breakup, EOP )) == NULL )
342 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"Missing ')' for breakup at '%s' in '%s'", *EOP, origStr );
348 return( spectralID );
363 char *sans[] = { (
char*)
"revision", NULL };
375 char **san, *sSan[] = { NULL };
377 if( sans == NULL ) sans = sSan;
381 for( qualifier = spectralID->
qualifiers, i = 0; qualifier != NULL; qualifier = qualifier->
next ) i++;
382 for( qualifier = spectralID->
qualifiers; qualifier != NULL; qualifier = qualifier->
next ) {
383 for( san = (
char **) sans; *san != NULL; san++ ) {
384 if( strcmp( *san, qualifier->
name ) == 0 ) {
392 for( qualifier = spectralID->
qualifiers; qualifier != NULL; qualifier = qualifier->
next ) {
393 for( san = (
char **) sans; *san != NULL; san++ )
if( strcmp( *san, qualifier->
name ) == 0 )
break;
394 if( *san != NULL )
continue;
409 if( (
gString_addTo( smr, gStr,
" -> " ) ) != 0 )
return( 1 );
423 for( s = str; ( *s != 0 ) && isspace( *s ); s++ ) ;
434 if( ( s = (
char*)
xData_malloc2( smr, n + 1, 0,
"s" ) ) == NULL )
return( NULL );
435 strncpy( s, str, n );
440#if defined __cplusplus
struct channelID_s channelID
int gString_addTo(statusMessageReporting *smr, gString *gStr, char const *str)
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
tpi_spectralIDQualifier * next
tpi_spectralIDQualifier * qualifiers
tpi_channelID * decayChannel
int tpi_spectralID_toStringSans(statusMessageReporting *smr, tpi_spectralID *spectralID, gString *gStr, char *sans[])
void * tpi_spectralID_free(statusMessageReporting *smr, tpi_spectralID *spectralID)
char * tpi_misc_allocateAndCopyNCharacters(statusMessageReporting *smr, char const *str, int n)
tpi_channelID * tpi_channelID_allocate(statusMessageReporting *smr)
int tpi_channelID_toString(statusMessageReporting *smr, tpi_channelID *channelID, gString *gStr)
int tpi_spectralID_toStringSanRevision(statusMessageReporting *smr, tpi_spectralID *spectralID, gString *gStr)
tpi_spectralID * tpi_spectralID_allocate(statusMessageReporting *smr)
tpi_spectralID * tpi_spectralID_parse(statusMessageReporting *smr, char const *str, char **EOP)
int tpi_spectralID_toString(statusMessageReporting *smr, tpi_spectralID *spectralID, gString *gStr)
char const * tpi_misc_firstNonWhiteSpace(statusMessageReporting *smr, char const *str)
void * tpi_channelID_free(statusMessageReporting *smr, tpi_channelID *channelID)
int tpi_channelID_toStringSans(statusMessageReporting *smr, tpi_channelID *channelID, gString *gStr, char *sans[])
int tpi_spectralID_initialize(statusMessageReporting *smr, tpi_spectralID *spectralID)
int tpi_channelID_release(statusMessageReporting *smr, tpi_channelID *channelID)
int tpi_channelID_toStringSanRevision(statusMessageReporting *smr, tpi_channelID *channelID, gString *gStr)
int tpi_channelID_initialize(statusMessageReporting *smr, tpi_channelID *channelID)
tpi_channelID * tpi_channelID_parse(statusMessageReporting *smr, char const *str, char **EOP)
int tpi_spectralID_release(statusMessageReporting *smr, tpi_spectralID *spectralID)
void * xData_free(statusMessageReporting *smr, void *p)
#define xData_malloc2(smr, size, zero, forItem)