1 #ifndef INCLUDED_ObjexxFCL_Fstring_hh
2 #define INCLUDED_ObjexxFCL_Fstring_hh
104 str_( new char[ 1 ] ),
117 str_( new char[ 1 ] ),
121 str_[ 0 ] =
static_cast< char >( c );
130 str_( new char[ 1 ] ),
134 str_[ 0 ] =
static_cast< char >( c );
140 Fstring(
short int const len_a );
150 Fstring(
long int const len_a );
155 Fstring(
unsigned short int const len_a );
160 Fstring(
unsigned int const len_a );
165 Fstring(
unsigned long int const len_a );
170 Fstring(
unsigned long long const len_a );
220 operator std::string()
const
259 return str_[ i - 1 ];
270 return str_[ i - 1 ];
282 return (
len_ == 0 );
329 has( std::string
const &
s )
const;
339 has(
char const c )
const;
373 template<
typename T >
383 std::istringstream t_stream( std::string(
str_ + b - 1, trimmed_whitespace_length ) );
386 return ( ( t_stream ) && ( t_stream.eof() ) );
396 return is_type< bool >();
405 return is_type< short int >();
414 return is_type< int >();
423 return is_type< long int >();
432 return is_type< unsigned short int >();
441 return is_type< unsigned int >();
450 return is_type< unsigned long int >();
459 return is_type< float >();
468 return is_type< double >();
477 return is_type< long double >();
486 return (
size() == 1 );
571 find( std::string
const &
s )
const;
581 find(
char const c )
const;
685 template<
typename T >
692 std::istringstream t_stream( std::string(
str_ + b - 1, trimmed_whitespace_length ) );
695 return ( ( t_stream ) && ( t_stream.eof() ) ? t :
T() );
704 return type_of< short int >();
713 return type_of< int >();
722 return type_of< long int >();
731 return type_of< unsigned short int >();
740 return type_of< unsigned int >();
749 return type_of< unsigned long int >();
758 return type_of< float >();
767 return type_of< double >();
776 return type_of< long double >();
785 return (
len_ == 1 ?
str_[ 0 ] :
char() );
848 strip( std::string
const & chars );
853 lstrip( std::string
const & chars );
858 rstrip( std::string
const & chars );
924 return Fstring( *this ).left_justify();
933 return Fstring( *this ).right_justify();
942 return Fstring( *this ).center();
951 return Fstring( *this ).compress();
960 return Fstring( *this ).lowercase();
969 return Fstring( *this ).uppercase();
1148 return ( static_cast< std::string >( s ) + t );
1158 return ( t + static_cast< std::string >( s ) );
1168 size_type const t_len( std::strlen( t ) );
1171 std::memcpy( u.
str_ + s.
len_, t, t_len );
1182 size_type const s_len( std::strlen( s ) );
1184 std::memcpy( u.
str_, s, s_len );
1379 return ( s.
lowercased() == std::tolower( c ) );
1389 return ( s.
lowercased() == std::tolower( c ) );
1414 return ( s.
lowercased() == std::tolower( c ) );
1427 return ( s.
lowercased() == std::tolower( c ) );
1663 get( std::istream & stream,
Fstring &
s );
1848 equal(
Fstring const &
s,
char const c,
bool const exact_case );
1853 equal(
char const c,
Fstring const &
s,
bool const exact_case );
1963 get( std::istream & stream,
Fstring &
s );
1995 return (
size() == 1 );
2015 return ( len_ == 1 ? str_[ 0 ] :
char() );
2025 return std::string( str_, len_ );
2141 return Fstring( static_cast< char >( i ) );
2150 return Fstring( static_cast< char >( i ) );
2162 assert( s.
length() == 1 );
2163 return static_cast< int >( s[ 1 ] );
2172 assert( s.
length() == 1 );
2173 return static_cast< int >( s[ 1 ] );
2182 return s.
find( ss );
2191 return s.
find( ss );
2477 template<
typename T >
2482 std::ostringstream t_stream;
2483 t_stream << std::uppercase << std::setprecision( TypeTraits< T >::precision() ) << t;
2484 return t_stream.str();
2499 template<
typename T >
2507 std::ostringstream t_stream;
2509 return t_stream.str();
2514 template<
typename T >
2523 std::ostringstream t_stream;
2526 return t_stream.str();
2531 template<
typename T >
2540 std::ostringstream t_stream;
2543 return t_stream.str();
2549 template<
typename T >
2557 std::ostringstream t_stream;
2560 return t_stream.str();
2565 template<
typename T >
2574 std::ostringstream t_stream;
2576 << std::setw(
w ) << std::setprecision(
p ) << t;
2577 return t_stream.str();
2582 template<
typename T >
2591 std::ostringstream t_stream;
2592 t_stream << std::right <<
std::uppercase << std::fixed << std::showpoint
2593 << std::setw(
w ) << std::setprecision(
p ) << t;
2594 return t_stream.str();
2599 template<
typename T >
2608 std::ostringstream t_stream;
2609 t_stream << std::right <<
std::uppercase << std::scientific << std::showpoint
2610 << std::setw(
w ) << std::setprecision(
p ) << t;
2611 return t_stream.str();
2619 template<
typename T >
2630 return ( ( t_stream ) && ( t_stream.eof() ) );
2651 return (
s.size() == 1 );
2660 return is_type< bool >(
s );
2669 return is_type< short int >(
s );
2678 return is_type< int >(
s );
2687 return is_type< long int >(
s );
2696 return is_type< unsigned short int >(
s );
2705 return is_type< unsigned int >(
s );
2714 return is_type< unsigned long int >(
s );
2723 return is_type< float >(
s );
2732 return is_type< double >(
s );
2741 return is_type< long double >(
s );
2764 template<
typename T >
2772 return ( ( t_stream ) && ( t_stream.eof() ) ? t :
T() );
2782 return std::string(
s );
2792 return (
s.size() == 1 ?
s[ 0 ] : char() );
2801 return type_of< short int >(
s );
2810 return type_of< int >(
s );
2819 return type_of< long int >(
s );
2828 return type_of< unsigned short int >(
s );
2837 return type_of< unsigned int >(
s );
2846 return type_of< unsigned long int >(
s );
2855 return type_of< float >(
s );
2864 return type_of< double >(
s );
2873 return type_of< long double >(
s );
2891 return std::string( s );
2898 #endif // INCLUDED_ObjexxFCL_Fstring_HH
std::istream & operator>>(std::istream &stream, byte &b)
Stream Input.
bool is_string(Fstring const &)
Fstring is Readable as a string?
friend bool operator>(Fstring const &s, Fstring const &t)
Fstring > Fstring.
friend bool operator==(Fstring const &s, Fstring const &t)
Fstring == Fstring.
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.
Fstring dncase(Fstring const &s)
Lowercased Copy.
char lowercased(char const c)
Lowercased Copy of a Character.
bool operator!=(byte const &i, byte const &j)
byte != byte
Fstring compress(Fstring const &s)
Compressed Copy.
unsigned long int ulong_of(Fstring const &s)
unsigned long int of an Fstring
Fstring & right_justify()
Right Justify.
Fstring & center()
Center.
Fstring lead_zero_Fstring_of(T const &t, int const w)
Leading-Zero Right-Justified Fstring of a Template Argument Type Supporting Stream Output...
void str_dncase(Fstring &s_out, Fstring const &s_in)
Lowercased Copy in an Output Fstring.
Fstring right_justified() const
Right-Justified Copy.
size_type find_last_whitespace() const
Find Last Occurrence of a Whitespace Character.
T type_of(Fstring const &s)
Type of an Fstring for Type Supporting Stream Input.
Fstring lowercased() const
Lowercased Copy.
bool is_short(Fstring const &s)
Fstring is Readable as a short int?
Fstring stripped() const
Space Stripped from Tails Copy.
size_type copy(cstring str, size_type const len_a, size_type const off=0) const
Copy to a Pre-Allocated String.
Fstring scientific_Fstring_of(T const &t, int const w=TypeTraits< T >::width(), int const p=TypeTraits< T >::precision())
Right-Justified Scientific Format Fstring of a Template Argument Type Supporting Stream Output...
friend std::istream & getline(std::istream &stream, Fstring &s)
Get Line from Stream.
bool is_blank(char const c)
Character is Blank?
bool operator>=(byte const &i, byte const &j)
byte >= byte
long double longdouble_of() const
long double of the Fstring
bool is_char() const
Fstring is Readable as a char?
std::string Fstring::type_of< std::string >() const
string of an Fstring
std::istream & read(std::istream &stream, Fstring &s)
Read from Stream.
unsigned short int ushort_of(Fstring const &s)
unsigned short int of an Fstring
Fstring & rstrip()
Strip Space from an Fstring's Right Tail.
bool is_short() const
Fstring is Readable as a short int?
std::istream & getline(std::istream &stream, Fstring &s)
Get Line from Stream.
bool equal(Fstring const &s, Fstring const &t, bool const exact_case=true)
Fstring == Fstring Case-Optionally?
friend bool operator<=(Fstring const &s, Fstring const &t)
Fstring <= Fstring.
cmplx w(cmplx z, double relerr)
Fstring & rstrip_whitespace()
Strip Whitespace from an Fstring's Right Tail.
int IACHAR(char const s)
ASCII Integer Value for a Given One-Character Fstring.
size_type find_whitespace() const
Find First Occurrence of a Whitespace Character.
size_type len() const
Length.
bool not_whitespace() const
Not whitespace?
unsigned short int ushort_of() const
unsigned short int of the Fstring
friend std::istream & read(std::istream &stream, Fstring &s)
Read from Stream.
T type_of() const
Type of an Fstring for Type Supporting Stream Input.
bool is_bool(Fstring const &s)
Fstring is Readable as a bool?
Fstring Fstring_of(T const &t)
Fstring of a Template Argument Type Supporting Stream Output.
Fsubstring(Fstring const &s, size_type const i, size_type const j)
Fstring Range Constructor.
bool operator<=(byte const &i, byte const &j)
byte <= byte
Fstring & overlay(Fstring const &s, size_type const pos=1)
Overlay an Fstring.
Fstring left_justified() const
Left-Justified Copy.
char operator[](size_type const i) const
Constant char: s[ i ].
Fstring stripped(std::string const &chars) const
Specified Characters Stripped from Tails Copy.
void(* InitializerFunction)(Fstring &)
bool is_uint() const
Fstring is Readable as an unsigned int?
c_cstring c_str() const
Null-Terminated cstring Copy of the Fstring that is Owned by the Fstring.
bool is_blank() const
Blank?
size_type find_last(Fstring const &s) const
Find Last Occurrence of an Fstring.
Fstring & strip_whitespace()
Strip Whitespace from an Fstring's Tails.
char type_of< char >(Fstring const &s)
char of an Fstring
size_type find_last_not_of(Fstring const &s) const
Find Last Occurrence of Any Character not of an Fstring.
Fsubstring & operator=(Fsubstring const &s)
Copy Assignment.
bool has_any_of(Fstring const &s) const
Has Any Character of an Fstring?
bool is_string() const
Fstring is Readable as a string?
char & lowercase(char &c)
Lowercase a Character.
size_type len_trim() const
Length Space-Trimmed.
TypeTraits: Type Traits Template.
bool is_longdouble(Fstring const &s)
Fstring is Readable as a long double?
bool is_double() const
Fstring is Readable as a double?
long double longdouble_of(Fstring const &s)
long double of an Fstring
Fstring & compress()
Compress Out Whitespace.
Fstring rstripped() const
Space Stripped from Right Tail Copy.
Fsubstring: Fixed-Length Fortran-Compatible Substring.
friend bool operator>=(Fstring const &s, Fstring const &t)
Fstring >= Fstring.
Fstring lstripped() const
Space Stripped from Left Tail Copy.
byte operator+(byte const &i, byte const &j)
byte + byte
Fstring::size_type len(Fstring const &s)
Length.
Fstring::size_type index(Fstring const &s, Fstring const &ss)
First Index Position of a Substring in an Fstring.
Fstring compressed() const
Compressed Copy.
bool lgt(char const s, char const t)
ASCII Lexical < Comparison.
bool is_longdouble() const
Fstring is Readable as a long double?
bool equal(char const c, Fstring const &s, bool const exact_case=true)
char == Fstring Case-Optionally?
size_type find_first_of(Fstring const &s) const
Find First Occurrence of Any Character of an Fstring.
virtual ~Fsubstring()
Destructor.
bool equal(Fstring const &s, char const c, bool const exact_case=true)
Fstring == char Case-Optionally?
Fsubstring(Fsubstring const &s)
Copy Constructor.
bool is_char(Fstring const &s)
Fstring is Readable as a char?
std::string type_of< std::string >(Fstring const &s)
string of an Fstring
c_cstring t_str() const
Whitespace-Trimmed Null-Terminated cstring Copy of the Fstring that is Owned by the Fstring...
std::string string_of() const
string of the Fstring
bool equali(char const c, char const d)
char == char Case-Insensitively
size_type find(Fstring const &s) const
Find First Occurrence of an Fstring.
size_type size() const
Size.
Fstring::size_type last_index(Fstring const &s, Fstring const &ss)
Last Index Position of a Substring in an Fstring.
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?
size_type find_first_not_of(Fstring const &s) const
Find First Occurrence of Any Character not of an Fstring.
Fstring rstripped(std::string const &chars) const
Specified Characters Stripped from Right Tail Copy.
Fstring uppercased() const
Uppercased Copy.
std::istream & readsome(std::istream &stream, Fstring &s)
Read Available Characters from Stream.
bool const sub_
Substring flag.
bool has_prefix(Fstring const &s, bool const exact_case=true) const
Has a Prefix Case-Optionally?
Fstring & lstrip()
Strip Space from an Fstring's Left Tail.
bool is_int() const
Fstring is Readable as an int?
Fstring(char const c)
char Constructor
size_type find_last_non_whitespace() const
Find Last Occurrence of a Non-Whitespace Character.
void(* initializer_function)(Fstring &)
c_cstring data() const
Non-Null-Terminated cstring Copy of the Fstring Data.
Fstring & operator=(Fstring const &s)
Copy Assignment.
Fstring & ref()
Reference to Fstring: Can Pass s( i, j ).ref() to an Fstring& Argument.
Fsubstring tail()
Space Tail Substring.
bool equal(char const c, char const d, bool const exact_case)
char == char Case-Optionally?
bool is_ushort() const
Fstring is Readable as a unsigned short int?
Fstring upcase(Fstring const &s)
Uppercased Copy.
Fstring::size_type len_trim(Fstring const &s)
Length Space-Trimmed.
Fstring rstripped_whitespace() const
Whitespace Stripped from Right Tail Copy.
Fstring & uppercase(Fstring &s)
Uppercase an Fstring.
bool has(Fstring const &s) const
Has an Fstring?
size_type find_non_whitespace() const
Find First Occurrence of a Non-Whitespace Character.
friend std::ostream & operator<<(std::ostream &stream, Fstring const &s)
Stream Output.
bool empty() const
Empty?
Fstring & trim_whitespace()
Trim Trailing Whitespace Replacing it with Space.
friend std::istream & operator>>(std::istream &stream, Fstring &s)
Stream Input.
virtual ~Fstring()
Destructor.
Fstring & lstrip_whitespace()
Strip Whitespace from an Fstring's Left Tail.
double double_of() const
double of the Fstring
size_type find_last_of(Fstring const &s) const
Find Last Occurrence of Any Character of an Fstring.
char char_of() const
char of the Fstring
Fstring centered() const
Centered Copy.
bool is_type< char >(Fstring const &s)
Fstring is Readable as a char Supporting Stream Input?
friend bool operator<(Fstring const &s, Fstring const &t)
Fstring < Fstring.
size_type length() const
Length.
bool is_ushort(Fstring const &s)
Fstring is Readable as a unsigned short int?
Fsubstring(Fstring const &s, size_type const i)
Fstring Tail Constructor.
bool is_type(Fstring const &s)
Fstring is Readable as a Type Supporting Stream Input?
bool is_long() const
Fstring is Readable as a long int?
int ICHAR(char const s)
Integer Value of a Given One-Character Fstring.
unsigned int uint_of(Fstring const &s)
unsigned int of an Fstring
friend std::istream & readsome(std::istream &stream, Fstring &s)
Read Available Characters from Stream.
bool is_int(Fstring const &s)
Fstring is Readable as an int?
float float_of(Fstring const &s)
float of an Fstring
Fstring(signed char const c)
signed char Constructor
Fstring ACHAR(int const i)
One-Character Fstring of a Given ASCII Integer Value.
Fstring(unsigned char const c)
unsigned char Constructor
friend bool operator!=(Fstring const &s, Fstring const &t)
Fstring != Fstring.
Fstring & trim()
Trim Trailing Space.
Fstring & left_justify()
Left Justify.
Fstring ljust(Fstring const &s)
Left-Justified Copy.
Fstring lstripped_whitespace() const
Whitespace Stripped from Left Tail Copy.
Fstring lstripped(std::string const &chars) const
Specified Characters Stripped from Left Tail Copy.
bool operator>(byte const &i, byte const &j)
byte > byte
Fstring left_Fstring_of(T const &t, int const w, char const f= ' ')
Left-Justified Fstring of a Template Argument Type Supporting Stream Output.
bool is_long(Fstring const &s)
Fstring is Readable as a long int?
Fstring fixed_Fstring_of(T const &t, int const w=TypeTraits< T >::width(), int const p=TypeTraits< T >::precision())
Right-Justified Fixed Format Fstring of a Template Argument Type Supporting Stream Output...
Fstring center(Fstring const &s)
Centered Copy.
Fsubstring const operator()(size_type const i, size_type const j) const
Constant Substring: s( i, j )
float float_of() const
float of the Fstring
int int_of() const
int of the Fstring
void str_upcase(Fstring &s_out, Fstring const &s_in)
Uppercased Copy in an Output Fstring.
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?
bool Fstring::is_type< std::string >() const
Fstring is Readable as a string Supporting Stream Input?
Fstring right_Fstring_of(T const &t, int const w, char const f= ' ')
Right-Justified Fstring of a Template Argument Type Supporting Stream Output.
bool llt(char const s, char const t)
ASCII Lexical < Comparison.
Fstring: Fixed-Length Fortran-Compatible String.
bool operator<(byte const &i, byte const &j)
byte < byte
Fstring general_Fstring_of(T const &t, int const w=TypeTraits< T >::width(), int const p=TypeTraits< T >::precision())
Right-Justified General Format Fstring of a Template Argument Type Supporting Stream Output...
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?
friend bool equali(Fstring const &s, Fstring const &t)
Fstring == Fstring Case-Insensitively?
unsigned long int ulong_of() const
unsigned long int of the Fstring
void init()
set global 'init_was_called' to true
bool is_whitespace() const
Whitespace?
Fstring rjust(Fstring const &s)
Right-Justified Copy.
void str_dn(Fstring &s)
Lowercase an Fstring.
void str_up(Fstring &s)
Uppercase an Fstring.
Fstring()
Default Constructor.
Fstring CHAR(int const i)
One-Character Fstring of a Given ASCII Integer Value.
std::ostream & operator<<(std::ostream &stream, CArray< T > const &a)
stream << CArray
bool not_blank() const
Not blank?
bool is_ulong() const
Fstring is Readable as a unsigned long int?
Fstring & uppercase()
Uppercase.
bool operator==(byte const &i, byte const &j)
byte == byte
Fstring & lowercase()
Lowercase.
Fstring trimmed_whitespace() const
Trailing Whitespace Trimmed Copy.
char uppercased(char const c)
Uppercased Copy of a Character.
bool lge(char const s, char const t)
ASCII Lexical >= Comparison.
long int long_of() const
long int of the Fstring
char & uppercase(char &c)
Uppercase a Character.
Fstring Fstring_of< std::string >(std::string const &t)
Fstring of a string Specialization.
char char_of(Fstring const &s)
char of an Fstring
bool is_bool() const
Fstring is Readable as a bool?
Fsubstring const head() const
Space-Free Head Constant Substring.
Fstring trimmed() const
Trailing Space Trimmed Copy.
bool is_type() const
Fstring is Readable as a Type Supporting Stream Input?
Fstring & strip()
Strip Space from an Fstring's Tails.
bool lle(char const s, char const t)
ASCII Lexical <= Comparison.
double double_of(Fstring const &s)
double of an Fstring
bool is_double(Fstring const &s)
Fstring is Readable as a double?
friend Fstring operator+(Fstring const &s, Fstring const &t)
Fstring + Fstring.
short int short_of(Fstring const &s)
short int of an Fstring
size_type trimmed_whitespace_range(size_type &b, size_type &e) const
Get Range of Whitespace-Trimmed Portion and Return its Length.
bool is_float(Fstring const &s)
Fstring is Readable as a float?
unsigned int uint_of() const
unsigned int of the Fstring
Fstring stripped_whitespace() const
Whitespace Stripped from Tails Copy.
bool is_float() const
Fstring is Readable as a float?
bool is_type< std::string >(Fstring const &)
Fstring is Readable as a string Supporting Stream Input?
short int short_of() const
short int of the Fstring
size_type len_trim_whitespace() const
Length Whitespace-Trimmed.