Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

String Namespace Reference


Detailed Description

General-purpose string utility functions.


Compounds

class  StreamFormat
 Convenience structure to wrap up and pass around a set of arguments for stream output, e.g. More...


Functions

template<class String> bool glob_match (const String &globstr, const String &teststr)
 Returns true if the specified globstr, which may include a "*" wildcard at the beginning and/or end (only!), matches the teststr.

template<class String> bool non_numeric_basename_matches (const String &a, const String &b)
 Returns true if the two strings of any type match up to trailing digits.

template<class T, class String> T numeric_extension (const String &a)
 Converts any trailing digits to the given type and returns them; result is undefined if there are no digits at the end.

template<class String> int integer_portion (const String &a)
 Returns the integer portion of the given string, which may represent either an integer or a floating-point number.

template<class String> int fractional_portion (const String &a)
 Returns the fractional portion of the given string, which may represent either an integer or a floating-point number.

unsigned C_identifier_length (const char *s, const char nonalnum='_')
 Returns the length of the prefix of the given string which consists entirely of characters allowed in C-language identifiers.

template<class String> unsigned C_identifier_length (const String &s, const char nonalnum='_')
template<class String> String strip_quotes (const String &s)
 Strips off one set of surrounding single or double quotes, if any are present.

template<class String> string replace_all (const String &s, const String &fromtext, const String &totext)
 Returns the result of replacing all instances of the given fromtext with the given totext.

std::ostream & operator<< (std::ostream &s, const StreamFormat &a)
 Instruct the given stream to use the specified formatting.

template<class T> string stringrep (const T &item, const StreamFormat format=StreamFormat())
 Convert the given item (such as an integer or a float) into a string.


Function Documentation

unsigned C_identifier_length const char *    s,
const char    nonalnum = '_'
[inline]
 

Returns the length of the prefix of the given string which consists entirely of characters allowed in C-language identifiers.

(First character must be alphabetical, and rest must be alphanumeric or an underscore.) An extra character nonalnum can be supplied which will also be accepted; if e.g. ':' namespace or class-qualified names will be accepted. If an explicit nonalnum is supplied, it will also be accepted in the first position of the identifier.

Definition at line 120 of file stringutils.h.

Referenced by ParameterMap< ParamT >::define_param().

template<class String>
int fractional_portion const String &    a
 

Returns the fractional portion of the given string, which may represent either an integer or a floating-point number.

If the string has no decimal point, zero is returned.

Definition at line 99 of file stringutils.h.

References StringParser::parse().

Referenced by String::StreamFormat::StreamFormat().

template<class String>
bool glob_match const String &    globstr,
const String &    teststr
 

Returns true if the specified globstr, which may include a "*" wildcard at the beginning and/or end (only!), matches the teststr.

Eventually it would be much better to replace it with a call to a full globbing or regular expression library, but this implementation was simpler for now. Callers should not assume that strings containing some wildcards that do not now match will continue not matching in future. If the teststr starts with a period, the result will be true only if it matches exactly.

startglob && endglob

Definition at line 26 of file stringutils.h.

template<class T>
string stringrep const T &    item,
const StreamFormat    format = StreamFormat()
 

Convert the given item (such as an integer or a float) into a string.

Specializations are required for objects that don't support the << operator or for whom the << output is inappropriate. If desired, output can be controlled using the StreamFormat argument.

Definition at line 248 of file stringutils.h.

Referenced by measure_stimulus_map_iteration< LoopContainer, UpdatableObjectContainer >::operator()(), StimulusParameterMapsForRegion< MapType, MapBaseType, ValuePointer >::register_maps(), ValueGenerator_Increment< T >::stringrep(), ValueGenerator_Opposite< T >::stringrep(), ValueGenerator_Correlate< T, RandomGen, crop >::stringrep(), ValueGenerator_Random< T, RandomGen >::stringrep(), ValueGenerator< T >::stringrep(), and PolymorphBase< string >::stringrep().


Generated on Mon Jan 20 02:37:46 2003 for RF-LISSOM by doxygen1.3-rc2