1 #ifndef INCLUDED_ObjexxFCL_string_functions_HH
2 #define INCLUDED_ObjexxFCL_string_functions_HH
41 equali( std::string
const &
s, std::string
const & t );
57 equal( std::string
const &
s, std::string
const & t,
bool const exact_case =
true )
75 return ( s.find_first_not_of(
' ' ) == std::string::npos );
97 return ( s.find_last_not_of(
" \t\000" ) == std::string::npos );
114 has( std::string
const &
s, std::string
const & t )
116 return ( s.find( t ) != std::string::npos );
125 return ( s.find( t ) != std::string::npos );
132 has( std::string
const &
s,
char const c )
134 return ( s.find( c ) != std::string::npos );
143 return ( s.find_first_of( t ) != std::string::npos );
152 return ( s.find( c ) != std::string::npos );
158 has_prefix( std::string
const &
s, std::string
const & pre,
bool const exact_case =
true );
163 has_suffix( std::string
const &
s, std::string
const & suf,
bool const exact_case =
true );
171 std::string::size_type
174 return s.find_last_not_of(
' ' ) + 1;
180 std::string::size_type
183 return s.find_last_not_of(
" \t\000" ) + 1;
212 trim( std::string &
s );
222 strip( std::string &
s, std::string
const & chars );
227 lstrip( std::string &
s, std::string
const & chars );
232 rstrip( std::string &
s, std::string
const & chars );
267 pad( std::string &
s, std::string::size_type
const len );
272 lpad( std::string &
s, std::string::size_type
const len );
277 rpad( std::string &
s, std::string::size_type
const len );
282 size( std::string &
s, std::string::size_type
const len );
292 center( std::string &
s, std::string::size_type
const len );
302 overlay( std::string &
s, std::string
const & t, std::string::size_type
const pos = 0 );
313 return std::string( len,
' ' );
349 stripped( std::string
const &
s, std::string
const & chars );
354 lstripped( std::string
const &
s, std::string
const & chars );
359 rstripped( std::string
const &
s, std::string
const & chars );
394 padded( std::string
const &
s, std::string::size_type
const len );
399 lpadded( std::string
const &
s, std::string::size_type
const len );
404 rpadded( std::string
const &
s, std::string::size_type
const len );
409 sized( std::string
const &
s, std::string::size_type
const len );
419 centered( std::string
const &
s, std::string::size_type
const len );
429 head( std::string
const &
s );
436 template<
typename T >
441 std::ostringstream t_stream;
442 t_stream << std::uppercase << std::setprecision( TypeTraits< T >::precision() ) << t;
443 return t_stream.str();
448 template<
typename T >
456 std::ostringstream t_stream;
458 return t_stream.str();
463 template<
typename T >
472 std::ostringstream t_stream;
475 return t_stream.str();
480 template<
typename T >
489 std::ostringstream t_stream;
492 return t_stream.str();
498 template<
typename T >
506 std::ostringstream t_stream;
509 return t_stream.str();
514 template<
typename T >
523 std::ostringstream t_stream;
525 << std::setw(
w ) << std::setprecision(
p ) << t;
526 return t_stream.str();
531 template<
typename T >
540 std::ostringstream t_stream;
541 t_stream << std::right <<
std::uppercase << std::fixed << std::showpoint
542 << std::setw(
w ) << std::setprecision(
p ) << t;
543 return t_stream.str();
548 template<
typename T >
557 std::ostringstream t_stream;
558 t_stream << std::right <<
std::uppercase << std::scientific << std::showpoint
559 << std::setw(
w ) << std::setprecision(
p ) << t;
560 return t_stream.str();
568 template<
typename T >
579 return ( ( t_stream ) && ( t_stream.eof() ) );
590 return (
s.length() == 1 );
599 return is_type< bool >(
s );
608 return is_type< short int >(
s );
617 return is_type< int >(
s );
629 return is_type< long int >(
s );
638 return is_type< unsigned short int >(
s );
647 return is_type< unsigned int >(
s );
656 return is_type< unsigned long int >(
s );
665 return is_type< float >(
s );
674 return is_type< double >(
s );
683 return is_type< long double >(
s );
697 template<
typename T >
705 return ( ( t_stream ) && ( t_stream.eof() ) ? t :
T() );
715 return (
s.length() == 1 ?
s[ 0 ] : char() );
724 return type_of< short int >(
s );
733 return type_of< int >(
s );
743 ints_of( std::string
const &
s,
bool & string_is_ok );
751 return type_of< long int >(
s );
760 return type_of< unsigned short int >(
s );
769 return type_of< unsigned int >(
s );
778 return type_of< unsigned long int >(
s );
787 return type_of< float >(
s );
796 return type_of< double >(
s );
805 return type_of< long double >(
s );
821 #endif // INCLUDED_ObjexxFCL_string_functions_HH
std::string fixed_string_of(T const &t, int const w=TypeTraits< T >::width(), int const p=TypeTraits< T >::precision())
Right-Justified Fixed Format string of a Template Argument Type Supporting Stream Output...
bool not_blank(char const c)
Character is Not Blank?
std::string & size(std::string &s, std::string::size_type const len)
Size a string to a Specified Length.
char lowercased(char const c)
Lowercased Copy of a Character.
bool has_suffix(std::string const &s, std::string const &suf, bool const exact_case)
Has a Suffix Case-Optionally?
unsigned long int ulong_of(Fstring const &s)
unsigned long int of an Fstring
std::string lead_zero_string_of(T const &t, int const w)
Leading-Zero Right-Justified string of a Template Argument Type Supporting Stream Output...
T type_of(Fstring const &s)
Type of an Fstring for Type Supporting Stream Input.
bool is_short(Fstring const &s)
Fstring is Readable as a short int?
std::string scientific_string_of(T const &t, int const w=TypeTraits< T >::width(), int const p=TypeTraits< T >::precision())
Right-Justified Scientific Format string of a Template Argument Type Supporting Stream Output...
bool is_blank(char const c)
Character is Blank?
std::string stripped_whitespace(std::string const &s)
Whitespace Stripped from a string's Tails Copy of a string.
std::string blank(std::string::size_type const len)
Blank string of Specified Length.
unsigned short int ushort_of(Fstring const &s)
unsigned short int of an Fstring
std::string & strip_whitespace(std::string &s)
Strip Whitespace from a string's Tails.
std::string & trim_whitespace(std::string &s)
Trim Trailing Whitespace from a string.
bool is_whitespace(std::string const &s)
string is Whitespace?
cmplx w(cmplx z, double relerr)
std::string general_string_of(T const &t, int const w=TypeTraits< T >::width(), int const p=TypeTraits< T >::precision())
Right-Justified General Format string of a Template Argument Type Supporting Stream Output...
bool is_bool(Fstring const &s)
Fstring is Readable as a bool?
std::string & overlay(std::string &s, std::string const &t, std::string::size_type const pos)
Overlay a string With Another string, Expanding Size as Needed.
std::string rstripped(std::string const &s, std::string const &chars)
Specified Characters Stripped from a string's Right Tail Copy of a string.
bool has(std::string const &s, std::string const &t)
string has a string?
bool has_prefix(std::string const &s, std::string const &pre, bool const exact_case)
Has a Prefix Case-Optionally?
char type_of< char >(Fstring const &s)
char of an Fstring
char & lowercase(char &c)
Lowercase a Character.
TypeTraits: Type Traits Template.
bool is_longdouble(Fstring const &s)
Fstring is Readable as a long double?
long double longdouble_of(Fstring const &s)
long double of an Fstring
std::string & lstrip_whitespace(std::string &s)
Strip Whitespace from a string's Left Tail.
Fstring::size_type len(Fstring const &s)
Length.
bool is_ints(std::string const &s)
ints of a string (e.g., allowing "5-8" to represent "5 6 7 8").
bool is_char(Fstring const &s)
Fstring is Readable as a char?
bool equali(char const c, char const d)
char == char Case-Insensitively
std::string & rstrip_whitespace(std::string &s)
Strip Whitespace from a string's Right Tail.
std::string right_string_of(T const &t, int const w, char const f= ' ')
Right-Justified string of a Template Argument Type Supporting Stream Output.
std::string padded(std::string const &s, std::string::size_type const len)
Padded to a Specified Length Copy of a string.
long int long_of(Fstring const &s)
long int of an Fstring
bool is_uint(Fstring const &s)
Fstring is Readable as an unsigned int?
std::string & pad(std::string &s, std::string::size_type const len)
Pad a string to a Specified Length.
std::string & strip(std::string &s, std::string const &chars)
Strip Specified Characters from a string's Tails.
std::string head(std::string const &s)
Space-Free Head Copy of a string.
std::string trimmed_whitespace(std::string const &s)
Trailing Whitespace Trimmed Copy of a string.
std::string rpadded(std::string const &s, std::string::size_type const len)
Right-Padded to a Specified Length Copy of a string.
bool equal(char const c, char const d, bool const exact_case)
char == char Case-Optionally?
std::string & trim(std::string &s)
Trim Trailing Space from a string.
std::string left_string_of(T const &t, int const w, char const f= ' ')
Left-Justified string of a Template Argument Type Supporting Stream Output.
Fstring::size_type len_trim(Fstring const &s)
Length Space-Trimmed.
std::string & lpad(std::string &s, std::string::size_type const len)
Left-Pad a string to a Specified Length.
std::string uniqued(std::string const &s)
Removed Repeat Characters from a Possibly Unsorted string Preserving Order Copy of a string...
std::string & unique(std::string &s)
Remove Repeat Characters from a Possibly Unsorted string Preserving Order.
std::string left_justified(std::string const &s)
Left-Justified Copy of a string.
bool not_whitespace(std::string const &s)
string is Not Whitespace?
std::string & rpad(std::string &s, std::string::size_type const len)
Right-Pad a string to a Specified Length.
std::string & lstrip(std::string &s, std::string const &chars)
Strip Specified Characters from a string's Left Tail.
bool is_type< char >(Fstring const &s)
Fstring is Readable as a char Supporting Stream Input?
bool is_ushort(Fstring const &s)
Fstring is Readable as a unsigned short int?
bool is_type(Fstring const &s)
Fstring is Readable as a Type Supporting Stream Input?
std::vector< int > ints_of(std::string const &s)
ints of a string (e.g., allowing "5-8" to represent "5 6 7 8").
unsigned int uint_of(Fstring const &s)
unsigned int of an Fstring
std::string stripped(std::string const &s, std::string const &chars)
Specified Characters Stripped from a string's Tails Copy of a string.
bool is_int(Fstring const &s)
Fstring is Readable as an int?
float float_of(Fstring const &s)
float of an Fstring
std::string lpadded(std::string const &s, std::string::size_type const len)
Left-Padded to a Specified Length Copy of a string.
std::string::size_type len_trim_whitespace(std::string const &s)
Length Whitespace-Trimmed.
std::string centered(std::string const &s)
Centered wrt Whitespace Copy of a string.
bool is_long(Fstring const &s)
Fstring is Readable as a long int?
Fstring center(Fstring const &s)
Centered Copy.
std::string & right_justify(std::string &s)
Right Justify a string.
std::string rstripped_whitespace(std::string const &s)
Whitespace Stripped from a string's Right Tail Copy of a string.
int int_of(Fstring const &s)
int of an Fstring
bool has_any_of(Fstring const &s, Fstring const &t)
Fstring Has Any Characters of a Set?
std::string lstripped(std::string const &s, std::string const &chars)
Specified Characters Stripped from a string's Left Tail Copy of a string.
Fstring trimmed(Fstring const &s)
Space-Trimmed Copy.
std::string string_of(Fstring const &s)
string of an Fstring
bool is_ulong(Fstring const &s)
Fstring is Readable as a unsigned long int?
std::string & rstrip(std::string &s, std::string const &chars)
Strip Specified Characters from a string's Right Tail.
std::string sized(std::string const &s, std::string::size_type const len)
Sized to a Specified Length Copy of a string.
char uppercased(char const c)
Uppercased Copy of a Character.
char & uppercase(char &c)
Uppercase a Character.
std::string right_justified(std::string const &s)
Right-Justified Copy of a string.
char char_of(Fstring const &s)
char of an Fstring
std::string lstripped_whitespace(std::string const &s)
Whitespace Stripped from a string's Left Tail Copy of a string.
std::string & left_justify(std::string &s)
Left Justify a string.
double double_of(Fstring const &s)
double of an Fstring
bool is_double(Fstring const &s)
Fstring is Readable as a double?
short int short_of(Fstring const &s)
short int of an Fstring
bool is_float(Fstring const &s)
Fstring is Readable as a float?