Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Fstring.hh
Go to the documentation of this file.
1 #ifndef INCLUDED_ObjexxFCL_Fstring_hh
2 #define INCLUDED_ObjexxFCL_Fstring_hh
3 
4 
5 // Fstring: Fixed-Length Fortran-Compatible String and Substring
6 //
7 // Project: Objexx Fortran Compatibility Library (ObjexxFCL)
8 //
9 // Version: 3.0.0
10 //
11 // Language: C++
12 //
13 // Copyright (c) 2000-2009 Objexx Engineering, Inc. All Rights Reserved.
14 // Use of this source code or any derivative of it is restricted by license.
15 // Licensing is available from Objexx Engineering, Inc.: http://objexx.com Objexx@objexx.com
16 
17 
18 // ObjexxFCL Headers
19 #include <ObjexxFCL/Fstring.fwd.hh>
21 #include <ObjexxFCL/TypeTraits.hh>
22 
23 // C++ Headers
24 #include <cassert>
25 #include <cctype>
26 #include <cstddef>
27 #include <cstring>
28 #include <iomanip>
29 #include <iosfwd>
30 #include <sstream>
31 #include <string>
32 
33 
34 namespace ObjexxFCL {
35 
36 
37 // Types
38 typedef char * cstring;
39 typedef char const * c_cstring;
40 
41 
42 /// @brief Fstring: Fixed-Length Fortran-Compatible String
43 ///
44 /// @remarks
45 /// @li Subscripts run from 1 to the length
46 /// @li Space-padding is used in comparisons and assignments
47 /// @li Internal string rep is not null-terminated
48 /// @li Zero-length Fstrings are supported but cannot be indexed into (no valid indices)
49 /// @li All the length constructors are needed to avoid ambiguity with the char constructor
50 /// @li Assignment can set length/string if Fstring is uninitialized (default constructed)
51 /// @li Substrings: Use s( i, j ) or s( i ) / Pass s( i, j ).ref() to a non-const Fstring& argument
52 /// @li Assumes that char is a single-byte ASCII-collated character
53 class Fstring
54 {
55 
56 
57 private: // Friend
58 
59 
60  friend class Fsubstring;
61 
62 
63 public: // Types
64 
65  // STL Style
66  typedef std::size_t size_type;
67  typedef void (*initializer_function)( Fstring & );
68 
69  // C++ Style
70  typedef std::size_t Size;
71  typedef void (*InitializerFunction)( Fstring & );
72 
73 
74 public: // Creation
75 
76 
77  /// @brief Default Constructor
78  inline
79  Fstring() :
80  len_( 0 ),
81  str_( 0 ),
82  c_str_( 0 ),
83  sub_( false )
84  {}
85 
86 
87  /// @brief Copy Constructor
88  Fstring( Fstring const & s );
89 
90 
91  /// @brief string Constructor
92  Fstring( std::string const & s );
93 
94 
95  /// @brief cstring Constructor
96  Fstring( c_cstring const s );
97 
98 
99  /// @brief char Constructor
100  inline
101  explicit
102  Fstring( char const c ) :
103  len_( 1 ),
104  str_( new char[ 1 ] ),
105  c_str_( 0 ),
106  sub_( false )
107  {
108  str_[ 0 ] = c;
109  }
110 
111 
112  /// @brief signed char Constructor
113  inline
114  explicit
115  Fstring( signed char const c ) :
116  len_( 1 ),
117  str_( new char[ 1 ] ),
118  c_str_( 0 ),
119  sub_( false )
120  {
121  str_[ 0 ] = static_cast< char >( c );
122  }
123 
124 
125  /// @brief unsigned char Constructor
126  inline
127  explicit
128  Fstring( unsigned char const c ) :
129  len_( 1 ),
130  str_( new char[ 1 ] ),
131  c_str_( 0 ),
132  sub_( false )
133  {
134  str_[ 0 ] = static_cast< char >( c );
135  }
136 
137 
138  /// @brief Length Constructor
139  explicit
140  Fstring( short int const len_a );
141 
142 
143  /// @brief Length Constructor
144  explicit
145  Fstring( int const len_a );
146 
147 
148  /// @brief Length Constructor
149  explicit
150  Fstring( long int const len_a );
151 
152 
153  /// @brief Length Constructor
154  explicit
155  Fstring( unsigned short int const len_a );
156 
157 
158  /// @brief Length Constructor
159  explicit
160  Fstring( unsigned int const len_a );
161 
162 
163  /// @brief Length Constructor
164  explicit
165  Fstring( unsigned long int const len_a );
166 
167 
168  /// @brief Length Constructor
169  explicit
170  Fstring( unsigned long long const len_a );
171 
172 
173  /// @brief Length + Fstring Constructor
174  Fstring( size_type const len_a, Fstring const & s );
175 
176 
177  /// @brief Length + string Constructor
178  Fstring( size_type const len_a, std::string const & s );
179 
180 
181  /// @brief Length + cstring Constructor
182  Fstring( size_type const len_a, c_cstring const s );
183 
184 
185  /// @brief Length + char Constructor
186  /// @note Fills with specified char => Use Fstring( len_a, "c" ) for space-padded single character
187  Fstring( size_type const len_a, char const c );
188 
189 
190  /// @brief Length + Initializer Constructor
191  Fstring( size_type const len_a, initializer_function init );
192 
193 
194  /// @brief Destructor
195  inline
196  virtual
198  {
199  if ( ! sub_ ) delete[] str_; // Substrings don't own/delete data
200  delete[] c_str_;
201  }
202 
203 
204 protected: // Creation
205 
206 
207  /// @brief Substring Range Constructor
208  Fstring( Fstring const & s, size_type const i, size_type const j );
209 
210 
211  /// @brief Substring Tail Constructor
212  Fstring( Fstring const & s, size_type const i );
213 
214 
215 public: // Conversion
216 
217 
218  /// @brief string Conversion
219  inline
220  operator std::string() const
221  {
222  return std::string( str_, len_ );
223  }
224 
225 
226 public: // Assignment
227 
228 
229  /// @brief Copy Assignment
230  Fstring &
231  operator =( Fstring const & s );
232 
233 
234  /// @brief = string
235  Fstring &
236  operator =( std::string const & s );
237 
238 
239  /// @brief = cstring
240  Fstring &
241  operator =( c_cstring const s );
242 
243 
244  /// @brief = char
245  Fstring &
246  operator =( char const c );
247 
248 
249 public: // Subscript
250 
251 
252  /// @brief Constant char: s[ i ]
253  inline
254  char
255  operator []( size_type const i ) const
256  {
257  assert( i > 0 );
258  assert( i <= len_ );
259  return str_[ i - 1 ];
260  }
261 
262 
263  /// @brief char: s[ i ]
264  inline
265  char &
267  {
268  assert( i > 0 );
269  assert( i <= len_ );
270  return str_[ i - 1 ];
271  }
272 
273 
274 public: // Predicate
275 
276 
277  /// @brief Empty?
278  inline
279  bool
280  empty() const
281  {
282  return ( len_ == 0 );
283  }
284 
285 
286  /// @brief Blank?
287  inline
288  bool
289  is_blank() const
290  {
291  return ( len_trim() == 0 );
292  }
293 
294 
295  /// @brief Not blank?
296  inline
297  bool
298  not_blank() const
299  {
300  return ( len_trim() > 0 );
301  }
302 
303 
304  /// @brief Whitespace?
305  inline
306  bool
308  {
309  return ( len_trim_whitespace() == 0 );
310  }
311 
312 
313  /// @brief Not whitespace?
314  inline
315  bool
317  {
318  return ( len_trim_whitespace() > 0 );
319  }
320 
321 
322  /// @brief Has an Fstring?
323  bool
324  has( Fstring const & s ) const;
325 
326 
327  /// @brief Has a string?
328  bool
329  has( std::string const & s ) const;
330 
331 
332  /// @brief Has a cstring?
333  bool
334  has( c_cstring const s ) const;
335 
336 
337  /// @brief Has a Character?
338  bool
339  has( char const c ) const;
340 
341 
342  /// @brief Has Any Character of an Fstring?
343  bool
344  has_any_of( Fstring const & s ) const;
345 
346 
347  /// @brief Has Any Character of a string?
348  bool
349  has_any_of( std::string const & s ) const;
350 
351 
352  /// @brief Has Any Character of a cstring?
353  bool
354  has_any_of( c_cstring const s ) const;
355 
356 
357  /// @brief Has a Character?
358  bool
359  has_any_of( char const c ) const;
360 
361 
362  /// @brief Has a Prefix Case-Optionally?
363  bool
364  has_prefix( Fstring const & s, bool const exact_case = true ) const;
365 
366 
367  /// @brief Has a Prefix Case-Optionally?
368  bool
369  has_prefix( c_cstring const s, bool const exact_case = true ) const;
370 
371 
372  /// @brief Fstring is Readable as a Type Supporting Stream Input?
373  template< typename T >
374  inline
375  bool
376  is_type() const
377  {
378  if ( is_whitespace() ) { // Don't accept empty or whitespace Fstring
379  return false;
380  } else { // Try to read the Fstring as a T
381  size_type b, e;
382  size_type const trimmed_whitespace_length( trimmed_whitespace_range( b, e ) );
383  std::istringstream t_stream( std::string( str_ + b - 1, trimmed_whitespace_length ) );
384  T t;
385  t_stream >> t;
386  return ( ( t_stream ) && ( t_stream.eof() ) );
387  }
388  }
389 
390 
391  /// @brief Fstring is Readable as a bool?
392  inline
393  bool
394  is_bool() const
395  {
396  return is_type< bool >();
397  }
398 
399 
400  /// @brief Fstring is Readable as a short int?
401  inline
402  bool
403  is_short() const
404  {
405  return is_type< short int >();
406  }
407 
408 
409  /// @brief Fstring is Readable as an int?
410  inline
411  bool
412  is_int() const
413  {
414  return is_type< int >();
415  }
416 
417 
418  /// @brief Fstring is Readable as a long int?
419  inline
420  bool
421  is_long() const
422  {
423  return is_type< long int >();
424  }
425 
426 
427  /// @brief Fstring is Readable as a unsigned short int?
428  inline
429  bool
430  is_ushort() const
431  {
432  return is_type< unsigned short int >();
433  }
434 
435 
436  /// @brief Fstring is Readable as an unsigned int?
437  inline
438  bool
439  is_uint() const
440  {
441  return is_type< unsigned int >();
442  }
443 
444 
445  /// @brief Fstring is Readable as a unsigned long int?
446  inline
447  bool
448  is_ulong() const
449  {
450  return is_type< unsigned long int >();
451  }
452 
453 
454  /// @brief Fstring is Readable as a float?
455  inline
456  bool
457  is_float() const
458  {
459  return is_type< float >();
460  }
461 
462 
463  /// @brief Fstring is Readable as a double?
464  inline
465  bool
466  is_double() const
467  {
468  return is_type< double >();
469  }
470 
471 
472  /// @brief Fstring is Readable as a long double?
473  inline
474  bool
476  {
477  return is_type< long double >();
478  }
479 
480 
481  /// @brief Fstring is Readable as a char?
482  inline
483  bool
484  is_char() const
485  {
486  return ( size() == 1 );
487  }
488 
489 
490  /// @brief Fstring is Readable as a string?
491  inline
492  bool
493  is_string() const
494  {
495  return true;
496  }
497 
498 
499 public: // Inspector
500 
501 
502  /// @brief Size
503  inline
504  size_type
505  size() const
506  {
507  return len_;
508  }
509 
510 
511  /// @brief Length
512  inline
513  size_type
514  length() const
515  {
516  return len_;
517  }
518 
519 
520  /// @brief Length
521  inline
522  size_type
523  len() const
524  {
525  return len_;
526  }
527 
528 
529  /// @brief Length Space-Trimmed
530  size_type
531  len_trim() const;
532 
533 
534  /// @brief Length Whitespace-Trimmed
535  size_type
536  len_trim_whitespace() const;
537 
538 
539  /// @brief Find First Occurrence of a Whitespace Character
540  size_type
541  find_whitespace() const;
542 
543 
544  /// @brief Find First Occurrence of a Non-Whitespace Character
545  size_type
546  find_non_whitespace() const;
547 
548 
549  /// @brief Find Last Occurrence of a Whitespace Character
550  size_type
551  find_last_whitespace() const;
552 
553 
554  /// @brief Find Last Occurrence of a Non-Whitespace Character
555  size_type
556  find_last_non_whitespace() const;
557 
558 
559  /// @brief Get Range of Whitespace-Trimmed Portion and Return its Length
560  size_type
562 
563 
564  /// @brief Find First Occurrence of an Fstring
565  size_type
566  find( Fstring const & s ) const;
567 
568 
569  /// @brief Find First Occurrence of a string
570  size_type
571  find( std::string const & s ) const;
572 
573 
574  /// @brief Find First Occurrence of a cstring
575  size_type
576  find( c_cstring const s ) const;
577 
578 
579  /// @brief Find First Occurrence of a Character
580  size_type
581  find( char const c ) const;
582 
583 
584  /// @brief Find Last Occurrence of an Fstring
585  size_type
586  find_last( Fstring const & s ) const;
587 
588 
589  /// @brief Find Last Occurrence of a string
590  size_type
591  find_last( std::string const & s ) const;
592 
593 
594  /// @brief Find Last Occurrence of a cstring
595  size_type
596  find_last( c_cstring const s ) const;
597 
598 
599  /// @brief Find Last Occurrence of a Character
600  size_type
601  find_last( char const c ) const;
602 
603 
604  /// @brief Find First Occurrence of Any Character of an Fstring
605  size_type
606  find_first_of( Fstring const & s ) const;
607 
608 
609  /// @brief Find First Occurrence of Any Character of a string
610  size_type
611  find_first_of( std::string const & s ) const;
612 
613 
614  /// @brief Find First Occurrence of Any Character of a cstring
615  size_type
616  find_first_of( c_cstring const s ) const;
617 
618 
619  /// @brief Find First Occurrence of a Character
620  size_type
621  find_first_of( char const c ) const;
622 
623 
624  /// @brief Find First Occurrence of Any Character not of an Fstring
625  size_type
626  find_first_not_of( Fstring const & s ) const;
627 
628 
629  /// @brief Find First Occurrence of Any Character not of a string
630  size_type
631  find_first_not_of( std::string const & s ) const;
632 
633 
634  /// @brief Find First Occurrence of Any Character not of a cstring
635  size_type
636  find_first_not_of( c_cstring const s ) const;
637 
638 
639  /// @brief Find First Occurrence of not a Character
640  size_type
641  find_first_not_of( char const c ) const;
642 
643 
644  /// @brief Find Last Occurrence of Any Character of an Fstring
645  size_type
646  find_last_of( Fstring const & s ) const;
647 
648 
649  /// @brief Find Last Occurrence of Any Character of a string
650  size_type
651  find_last_of( std::string const & s ) const;
652 
653 
654  /// @brief Find Last Occurrence of Any Character of a cstring
655  size_type
656  find_last_of( c_cstring const s ) const;
657 
658 
659  /// @brief Find Last Occurrence of a Character
660  size_type
661  find_last_of( char const c ) const;
662 
663 
664  /// @brief Find Last Occurrence of Any Character not of an Fstring
665  size_type
666  find_last_not_of( Fstring const & s ) const;
667 
668 
669  /// @brief Find Last Occurrence of Any Character not of a string
670  size_type
671  find_last_not_of( std::string const & s ) const;
672 
673 
674  /// @brief Find Last Occurrence of Any Character not of a cstring
675  size_type
676  find_last_not_of( c_cstring const s ) const;
677 
678 
679  /// @brief Find Last Occurrence not of a Character
680  size_type
681  find_last_not_of( char const c ) const;
682 
683 
684  /// @brief Type of an Fstring for Type Supporting Stream Input
685  template< typename T >
686  inline
687  T
688  type_of() const
689  {
690  size_type b, e;
691  size_type const trimmed_whitespace_length( trimmed_whitespace_range( b, e ) );
692  std::istringstream t_stream( std::string( str_ + b - 1, trimmed_whitespace_length ) );
693  T t;
694  t_stream >> t;
695  return ( ( t_stream ) && ( t_stream.eof() ) ? t : T() ); // Check is_type first
696  }
697 
698 
699  /// @brief short int of the Fstring
700  inline
701  short int
702  short_of() const
703  {
704  return type_of< short int >();
705  }
706 
707 
708  /// @brief int of the Fstring
709  inline
710  int
711  int_of() const
712  {
713  return type_of< int >();
714  }
715 
716 
717  /// @brief long int of the Fstring
718  inline
719  long int
720  long_of() const
721  {
722  return type_of< long int >();
723  }
724 
725 
726  /// @brief unsigned short int of the Fstring
727  inline
728  unsigned short int
729  ushort_of() const
730  {
731  return type_of< unsigned short int >();
732  }
733 
734 
735  /// @brief unsigned int of the Fstring
736  inline
737  unsigned int
738  uint_of() const
739  {
740  return type_of< unsigned int >();
741  }
742 
743 
744  /// @brief unsigned long int of the Fstring
745  inline
746  unsigned long int
747  ulong_of() const
748  {
749  return type_of< unsigned long int >();
750  }
751 
752 
753  /// @brief float of the Fstring
754  inline
755  float
756  float_of() const
757  {
758  return type_of< float >();
759  }
760 
761 
762  /// @brief double of the Fstring
763  inline
764  double
765  double_of() const
766  {
767  return type_of< double >();
768  }
769 
770 
771  /// @brief long double of the Fstring
772  inline
773  long double
775  {
776  return type_of< long double >();
777  }
778 
779 
780  /// @brief char of the Fstring
781  inline
782  char
783  char_of() const
784  {
785  return ( len_ == 1 ? str_[ 0 ] : char() ); // Check is_type first
786  }
787 
788 
789  /// @brief string of the Fstring
790  inline
791  std::string
792  string_of() const
793  {
794  return std::string( str_, len_ );
795  }
796 
797 
798 public: // Modifier
799 
800 
801  /// @brief Lowercase
802  Fstring &
803  lowercase();
804 
805 
806  /// @brief Uppercase
807  Fstring &
808  uppercase();
809 
810 
811  /// @brief Left Justify
812  Fstring &
813  left_justify();
814 
815 
816  /// @brief Right Justify
817  Fstring &
818  right_justify();
819 
820 
821  /// @brief Center
822  Fstring &
823  center();
824 
825 
826  /// @brief Compress Out Whitespace
827  Fstring &
828  compress();
829 
830 
831  /// @brief Trim Trailing Space
832  /// @note No effect for Fstring: Included for interface consistency
833  inline
834  Fstring &
836  {
837  return *this;
838  }
839 
840 
841  /// @brief Trim Trailing Whitespace Replacing it with Space
842  Fstring &
843  trim_whitespace();
844 
845 
846  /// @brief Strip Specified Characters from an Fstring's Tails
847  Fstring &
848  strip( std::string const & chars );
849 
850 
851  /// @brief Strip Specified Characters from an Fstring's Left Tail
852  Fstring &
853  lstrip( std::string const & chars );
854 
855 
856  /// @brief Strip Specified Characters from an Fstring's Right Tail
857  Fstring &
858  rstrip( std::string const & chars );
859 
860 
861  /// @brief Strip Space from an Fstring's Tails
862  Fstring &
863  strip();
864 
865 
866  /// @brief Strip Space from an Fstring's Left Tail
867  Fstring &
868  lstrip();
869 
870 
871  /// @brief Strip Space from an Fstring's Right Tail
872  Fstring &
873  rstrip();
874 
875 
876  /// @brief Strip Whitespace from an Fstring's Tails
877  Fstring &
879 
880 
881  /// @brief Strip Whitespace from an Fstring's Left Tail
882  Fstring &
884 
885 
886  /// @brief Strip Whitespace from an Fstring's Right Tail
887  Fstring &
889 
890 
891  /// @brief Clear
892  inline
893  Fstring &
895  {
896  std::memset( str_, ' ', len_ );
897  return *this;
898  }
899 
900 
901  /// @brief Overlay an Fstring
902  Fstring &
903  overlay( Fstring const & s, size_type const pos = 1 );
904 
905 
906  /// @brief Overlay a string
907  Fstring &
908  overlay( std::string const & s, size_type const pos = 1 );
909 
910 
911  /// @brief Overlay a cstring
912  Fstring &
913  overlay( c_cstring const s, size_type const pos = 1 );
914 
915 
916 public: // Generator
917 
918 
919  /// @brief Left-Justified Copy
920  inline
921  Fstring
923  {
924  return Fstring( *this ).left_justify();
925  }
926 
927 
928  /// @brief Right-Justified Copy
929  inline
930  Fstring
932  {
933  return Fstring( *this ).right_justify();
934  }
935 
936 
937  /// @brief Centered Copy
938  inline
939  Fstring
940  centered() const
941  {
942  return Fstring( *this ).center();
943  }
944 
945 
946  /// @brief Compressed Copy
947  inline
948  Fstring
949  compressed() const
950  {
951  return Fstring( *this ).compress();
952  }
953 
954 
955  /// @brief Lowercased Copy
956  inline
957  Fstring
958  lowercased() const
959  {
960  return Fstring( *this ).lowercase();
961  }
962 
963 
964  /// @brief Uppercased Copy
965  inline
966  Fstring
967  uppercased() const
968  {
969  return Fstring( *this ).uppercase();
970  }
971 
972 
973  /// @brief Trailing Space Trimmed Copy
974  inline
975  Fstring
976  trimmed() const
977  {
978  return Fstring( *this, 1, len_trim() );
979  }
980 
981 
982  /// @brief Trailing Whitespace Trimmed Copy
983  inline
984  Fstring
986  {
987  return Fstring( *this, 1, len_trim_whitespace() );
988  }
989 
990 
991  /// @brief Specified Characters Stripped from Tails Copy
992  inline
993  Fstring
994  stripped( std::string const & chars ) const
995  {
996  size_type const ib( find_first_not_of( chars ) );
997  if ( ib > 0 ) {
998  return Fstring( *this, ib, find_last_not_of( chars ) );
999  } else {
1000  return Fstring();
1001  }
1002  }
1003 
1004 
1005  /// @brief Specified Characters Stripped from Left Tail Copy
1006  inline
1007  Fstring
1008  lstripped( std::string const & chars ) const
1009  {
1010  size_type const ib( find_first_not_of( chars ) );
1011  if ( ib > 0 ) {
1012  return Fstring( *this, ib );
1013  } else {
1014  return Fstring();
1015  }
1016  }
1017 
1018 
1019  /// @brief Specified Characters Stripped from Right Tail Copy
1020  inline
1021  Fstring
1022  rstripped( std::string const & chars ) const
1023  {
1024  return Fstring( *this, 1, find_last_not_of( chars ) );
1025  }
1026 
1027 
1028  /// @brief Space Stripped from Tails Copy
1029  inline
1030  Fstring
1031  stripped() const
1032  {
1033  size_type const ib( find_first_not_of( ' ' ) );
1034  if ( ib > 0 ) {
1035  return Fstring( *this, ib, find_last_not_of( ' ' ) );
1036  } else {
1037  return Fstring();
1038  }
1039  }
1040 
1041 
1042  /// @brief Space Stripped from Left Tail Copy
1043  inline
1044  Fstring
1045  lstripped() const
1046  {
1047  size_type const ib( find_first_not_of( ' ' ) );
1048  if ( ib > 0 ) {
1049  return Fstring( *this, ib );
1050  } else {
1051  return Fstring();
1052  }
1053  }
1054 
1055 
1056  /// @brief Space Stripped from Right Tail Copy
1057  inline
1058  Fstring
1059  rstripped() const
1060  {
1061  return Fstring( *this, 1, find_last_not_of( ' ' ) );
1062  }
1063 
1064 
1065  /// @brief Whitespace Stripped from Tails Copy
1066  inline
1067  Fstring
1069  {
1070  size_type const ib( find_first_not_of( " \t\000" ) );
1071  if ( ib > 0 ) {
1072  return Fstring( *this, ib, find_last_not_of( " \t\000" ) );
1073  } else {
1074  return Fstring();
1075  }
1076  }
1077 
1078 
1079  /// @brief Whitespace Stripped from Left Tail Copy
1080  inline
1081  Fstring
1083  {
1084  size_type const ib( find_first_not_of( " \t\000" ) );
1085  if ( ib > 0 ) {
1086  return Fstring( *this, ib );
1087  } else {
1088  return Fstring();
1089  }
1090  }
1091 
1092 
1093  /// @brief Whitespace Stripped from Right Tail Copy
1094  inline
1095  Fstring
1097  {
1098  return Fstring( *this, 1, find_last_not_of( " \t\000" ) );
1099  }
1100 
1101 
1102  /// @brief Null-Terminated cstring Copy of the Fstring that is Owned by the Fstring
1103  c_cstring
1104  c_str() const;
1105 
1106 
1107  /// @brief Whitespace-Trimmed Null-Terminated cstring Copy of the Fstring that is Owned by the Fstring
1108  c_cstring
1109  t_str() const;
1110 
1111 
1112  /// @brief Non-Null-Terminated cstring Copy of the Fstring Data
1113  inline
1114  c_cstring
1115  data() const
1116  {
1117  return str_;
1118  }
1119 
1120 
1121  /// @brief Copy to a Pre-Allocated String
1122  size_type
1123  copy( cstring str, size_type const len_a, size_type const off = 0 ) const;
1124 
1125 
1126 public: // Concatenation
1127 
1128 
1129  /// @brief Fstring + Fstring
1130  friend
1131  inline
1132  Fstring
1133  operator +( Fstring const & s, Fstring const & t )
1134  {
1135  Fstring u( static_cast< size_type >( s.len_ + t.len_ ) );
1136  std::memcpy( u.str_, s.str_, s.len_ );
1137  std::memcpy( u.str_ + s.len_, t.str_, t.len_ );
1138  return u;
1139  }
1140 
1141 
1142  /// @brief Fstring + string
1143  friend
1144  inline
1145  std::string
1146  operator +( Fstring const & s, std::string const & t )
1147  {
1148  return ( static_cast< std::string >( s ) + t );
1149  }
1150 
1151 
1152  /// @brief string + Fstring
1153  friend
1154  inline
1155  std::string
1156  operator +( std::string const & t, Fstring const & s )
1157  {
1158  return ( t + static_cast< std::string >( s ) );
1159  }
1160 
1161 
1162  /// @brief Fstring + cstring
1163  friend
1164  inline
1165  Fstring
1166  operator +( Fstring const & s, c_cstring const t )
1167  {
1168  size_type const t_len( std::strlen( t ) );
1169  Fstring u( s.len_ + t_len );
1170  std::memcpy( u.str_, s.str_, s.len_ );
1171  std::memcpy( u.str_ + s.len_, t, t_len );
1172  return u;
1173  }
1174 
1175 
1176  /// @brief cstring + Fstring
1177  friend
1178  inline
1179  Fstring
1180  operator +( c_cstring const s, Fstring const & t )
1181  {
1182  size_type const s_len( std::strlen( s ) );
1183  Fstring u( s_len + t.len_ );
1184  std::memcpy( u.str_, s, s_len );
1185  std::memcpy( u.str_ + s_len, t.str_, t.len_ );
1186  return u;
1187  }
1188 
1189 
1190  /// @brief Fstring + char
1191  friend
1192  inline
1193  Fstring
1194  operator +( Fstring const & s, char const c )
1195  {
1196  Fstring u( s.len_ + 1 );
1197  std::memcpy( u.str_, s.str_, s.len_ );
1198  u.str_[ s.len_ ] = c;
1199  return u;
1200  }
1201 
1202 
1203  /// @brief char + Fstring
1204  friend
1205  inline
1206  Fstring
1207  operator +( char const c, Fstring const & s )
1208  {
1209  Fstring u( 1 + s.len_ );
1210  u.str_[ 0 ] = c;
1211  std::memcpy( u.str_ + 1, s.str_, s.len_ );
1212  return u;
1213  }
1214 
1215 
1216 public: // Comparison
1217 
1218 
1219  /// @brief Fstring == Fstring
1220  friend
1221  bool
1222  operator ==( Fstring const & s, Fstring const & t );
1223 
1224 
1225  /// @brief Fstring != Fstring
1226  friend
1227  inline
1228  bool
1229  operator !=( Fstring const & s, Fstring const & t )
1230  {
1231  return !( s == t );
1232  }
1233 
1234 
1235  /// @brief Fstring == string
1236  friend
1237  bool
1238  operator ==( Fstring const & s, std::string const & t );
1239 
1240 
1241  /// @brief string == Fstring
1242  friend
1243  inline
1244  bool
1245  operator ==( std::string const & t, Fstring const & s )
1246  {
1247  return ( s == t );
1248  }
1249 
1250 
1251  /// @brief Fstring != string
1252  friend
1253  inline
1254  bool
1255  operator !=( Fstring const & s, std::string const & t )
1256  {
1257  return !( s == t );
1258  }
1259 
1260 
1261  /// @brief string != Fstring
1262  friend
1263  inline
1264  bool
1265  operator !=( std::string const & t, Fstring const & s )
1266  {
1267  return !( s == t );
1268  }
1269 
1270 
1271  /// @brief Fstring == cstring
1272  friend
1273  bool
1274  operator ==( Fstring const & s, c_cstring const t );
1275 
1276 
1277  /// @brief cstring == Fstring
1278  friend
1279  inline
1280  bool
1281  operator ==( c_cstring const t, Fstring const & s )
1282  {
1283  return ( s == t );
1284  }
1285 
1286 
1287  /// @brief Fstring != cstring
1288  friend
1289  inline
1290  bool
1291  operator !=( Fstring const & s, c_cstring const t )
1292  {
1293  return !( s == t );
1294  }
1295 
1296 
1297  /// @brief cstring != Fstring
1298  friend
1299  inline
1300  bool
1301  operator !=( c_cstring const t, Fstring const & s )
1302  {
1303  return !( s == t );
1304  }
1305 
1306 
1307  /// @brief Fstring == char
1308  friend
1309  bool
1310  operator ==( Fstring const & s, char const c );
1311 
1312 
1313  /// @brief char == Fstring
1314  friend
1315  inline
1316  bool
1317  operator ==( char const c, Fstring const & s )
1318  {
1319  return ( s == c );
1320  }
1321 
1322 
1323  /// @brief Fstring != char
1324  friend
1325  inline
1326  bool
1327  operator !=( Fstring const & s, char const c )
1328  {
1329  return !( s == c );
1330  }
1331 
1332 
1333  /// @brief char != Fstring
1334  friend
1335  inline
1336  bool
1337  operator !=( char const c, Fstring const & s )
1338  {
1339  return !( s == c );
1340  }
1341 
1342 
1343  /// @brief Fstring == Fstring Case-Insensitively?
1344  friend
1345  inline
1346  bool
1347  equali( Fstring const & s, Fstring const & t )
1348  {
1349  return ( s.lowercased() == t.lowercased() );
1350  }
1351 
1352 
1353  /// @brief Fstring == string Case-Insensitively?
1354  friend
1355  inline
1356  bool
1357  equali( Fstring const & s, std::string const & t )
1358  {
1359  return ( s.lowercased() == ObjexxFCL::lowercased( t ) );
1360  }
1361 
1362 
1363  /// @brief string == Fstring Case-Insensitively?
1364  friend
1365  inline
1366  bool
1367  equali( std::string const & s, Fstring const & t )
1368  {
1369  return ( ObjexxFCL::lowercased( s ) == t.lowercased() );
1370  }
1371 
1372 
1373  /// @brief Fstring == char Case-Insensitively?
1374  friend
1375  inline
1376  bool
1377  equali( Fstring const & s, char const c )
1378  {
1379  return ( s.lowercased() == std::tolower( c ) );
1380  }
1381 
1382 
1383  /// @brief char == Fstring Case-Insensitively?
1384  friend
1385  inline
1386  bool
1387  equali( char const c, Fstring const & s )
1388  {
1389  return ( s.lowercased() == std::tolower( c ) );
1390  }
1391 
1392 
1393  /// @brief Fstring == Fstring Case-Optionally?
1394  inline
1395  bool
1396  equal( Fstring const & s, Fstring const & t, bool const exact_case = true )
1397  {
1398  if ( exact_case ) {
1399  return ( s == t );
1400  } else {
1401  return ( s.lowercased() == t.lowercased() );
1402  }
1403  }
1404 
1405 
1406  /// @brief Fstring == char Case-Optionally?
1407  inline
1408  bool
1409  equal( Fstring const & s, char const c, bool const exact_case = true )
1410  {
1411  if ( exact_case ) {
1412  return ( s == c );
1413  } else {
1414  return ( s.lowercased() == std::tolower( c ) );
1415  }
1416  }
1417 
1418 
1419  /// @brief char == Fstring Case-Optionally?
1420  inline
1421  bool
1422  equal( char const c, Fstring const & s, bool const exact_case = true )
1423  {
1424  if ( exact_case ) {
1425  return ( s == c );
1426  } else {
1427  return ( s.lowercased() == std::tolower( c ) );
1428  }
1429  }
1430 
1431 
1432  /// @brief Fstring <= Fstring
1433  friend
1434  bool
1435  operator <=( Fstring const & s, Fstring const & t );
1436 
1437 
1438  /// @brief Fstring < Fstring
1439  friend
1440  bool
1441  operator <( Fstring const & s, Fstring const & t );
1442 
1443 
1444  /// @brief Fstring >= Fstring
1445  friend
1446  inline
1447  bool
1448  operator >=( Fstring const & s, Fstring const & t )
1449  {
1450  return !( s < t );
1451  }
1452 
1453 
1454  /// @brief Fstring > Fstring
1455  friend
1456  inline
1457  bool
1458  operator >( Fstring const & s, Fstring const & t )
1459  {
1460  return !( s <= t );
1461  }
1462 
1463 
1464  /// @brief Fstring <= string
1465  friend
1466  bool
1467  operator <=( Fstring const & s, std::string const & t );
1468 
1469 
1470  /// @brief Fstring < string
1471  friend
1472  bool
1473  operator <( Fstring const & s, std::string const & t );
1474 
1475 
1476  /// @brief Fstring >= string
1477  friend
1478  inline
1479  bool
1480  operator >=( Fstring const & s, std::string const & t )
1481  {
1482  return !( s < t );
1483  }
1484 
1485 
1486  /// @brief Fstring > string
1487  friend
1488  inline
1489  bool
1490  operator >( Fstring const & s, std::string const & t )
1491  {
1492  return !( s <= t );
1493  }
1494 
1495 
1496  /// @brief string <= Fstring
1497  friend
1498  inline
1499  bool
1500  operator <=( std::string const & s, Fstring const & t )
1501  {
1502  return ( t >= s );
1503  }
1504 
1505 
1506  /// @brief string < Fstring
1507  friend
1508  inline
1509  bool
1510  operator <( std::string const & s, Fstring const & t )
1511  {
1512  return ( t > s );
1513  }
1514 
1515 
1516  /// @brief string >= Fstring
1517  friend
1518  inline
1519  bool
1520  operator >=( std::string const & s, Fstring const & t )
1521  {
1522  return ( t <= s );
1523  }
1524 
1525 
1526  /// @brief string > Fstring
1527  friend
1528  inline
1529  bool
1530  operator >( std::string const & s, Fstring const & t )
1531  {
1532  return ( t < s );
1533  }
1534 
1535 
1536  /// @brief Fstring <= cstring
1537  friend
1538  bool
1539  operator <=( Fstring const & s, c_cstring const t );
1540 
1541 
1542  /// @brief Fstring < cstring
1543  friend
1544  bool
1545  operator <( Fstring const & s, c_cstring const t );
1546 
1547 
1548  /// @brief Fstring >= cstring
1549  friend
1550  inline
1551  bool
1552  operator >=( Fstring const & s, c_cstring const t )
1553  {
1554  return !( s < t );
1555  }
1556 
1557 
1558  /// @brief Fstring > cstring
1559  friend
1560  inline
1561  bool
1562  operator >( Fstring const & s, c_cstring const t )
1563  {
1564  return !( s <= t );
1565  }
1566 
1567 
1568  /// @brief cstring <= Fstring
1569  friend
1570  inline
1571  bool
1572  operator <=( c_cstring const s, Fstring const & t )
1573  {
1574  return ( t >= s );
1575  }
1576 
1577 
1578  /// @brief cstring < Fstring
1579  friend
1580  inline
1581  bool
1582  operator <( c_cstring const s, Fstring const & t )
1583  {
1584  return ( t > s );
1585  }
1586 
1587 
1588  /// @brief cstring >= Fstring
1589  friend
1590  inline
1591  bool
1592  operator >=( c_cstring const s, Fstring const & t )
1593  {
1594  return ( t <= s );
1595  }
1596 
1597 
1598  /// @brief cstring > Fstring
1599  friend
1600  inline
1601  bool
1602  operator >( c_cstring const s, Fstring const & t )
1603  {
1604  return ( t < s );
1605  }
1606 
1607 
1608 public: // Substring
1609 
1610 
1611  /// @brief Constant Substring: s( i, j )
1612  Fsubstring const
1613  operator ()( size_type const i, size_type const j ) const;
1614 
1615 
1616  /// @brief Substring: s( i, j )
1617  Fsubstring
1618  operator ()( size_type const i, size_type const j );
1619 
1620 
1621  /// @brief Constant Tail Substring: s( i )
1622  Fstring const
1623  operator ()( size_type const i ) const;
1624 
1625 
1626  /// @brief Tail Substring: s( i )
1627  Fsubstring
1628  operator ()( size_type const i );
1629 
1630 
1631  /// @brief Space-Free Head Constant Substring
1632  Fsubstring const
1633  head() const;
1634 
1635 
1636  /// @brief Space-Free Head Substring
1637  Fsubstring
1638  head();
1639 
1640 
1641  /// @brief Space Tail Substring
1642  Fsubstring
1643  tail();
1644 
1645 
1646  /// @brief Space Tail Constant Substring
1647  Fsubstring const
1648  tail() const;
1649 
1650 
1651 public: // I/O
1652 
1653 
1654  /// @brief Stream Input
1655  friend
1656  std::istream &
1657  operator >>( std::istream & stream, Fstring & s );
1658 
1659 
1660  /// @brief Get from Stream
1661  friend
1662  std::istream &
1663  get( std::istream & stream, Fstring & s );
1664 
1665 
1666  /// @brief Get Line from Stream
1667  friend
1668  std::istream &
1669  getline( std::istream & stream, Fstring & s );
1670 
1671 
1672  /// @brief Read from Stream
1673  friend
1674  std::istream &
1675  read( std::istream & stream, Fstring & s );
1676 
1677 
1678  /// @brief Read Available Characters from Stream
1679  friend
1680  std::istream &
1681  readsome( std::istream & stream, Fstring & s );
1682 
1683 
1684  /// @brief Stream Output
1685  friend
1686  std::ostream &
1687  operator <<( std::ostream & stream, Fstring const & s );
1688 
1689 
1690 private: // Data
1691 
1692 
1693  /// @brief Length
1695 
1696  /// @brief String
1697  char * str_;
1698 
1699  /// @brief cstring
1700  mutable char * c_str_;
1701 
1702  /// @brief Substring flag
1703  bool const sub_;
1704 
1705 
1706 }; // Fstring
1707 
1708 
1709 /// @brief Fstring + Fstring
1710 Fstring
1711 operator +( Fstring const & s, Fstring const & t );
1712 
1713 
1714 /// @brief Fstring + string
1715 std::string
1716 operator +( Fstring const & s, std::string const & t );
1717 
1718 
1719 /// @brief string + Fstring
1720 #ifndef __clang__
1721 std::string
1722 operator +( std::string const & t, Fstring const & s );
1723 #endif
1724 
1725 
1726 /// @brief Fstring + cstring
1727 Fstring
1728 operator +( Fstring const & s, c_cstring const t );
1729 
1730 
1731 /// @brief cstring + Fstring
1732 Fstring
1733 operator +( c_cstring const s, Fstring const & t );
1734 
1735 
1736 /// @brief Fstring + char
1737 Fstring
1738 operator +( Fstring const & s, char const c );
1739 
1740 
1741 /// @brief char + Fstring
1742 Fstring
1743 operator +( char const c, Fstring const & s );
1744 
1745 
1746 /// @brief Fstring == Fstring
1747 bool
1748 operator ==( Fstring const & s, Fstring const & t );
1749 
1750 
1751 /// @brief Fstring != Fstring
1752 bool
1753 operator !=( Fstring const & s, Fstring const & t );
1754 
1755 
1756 /// @brief Fstring == string
1757 bool
1758 operator ==( Fstring const & s, std::string const & t );
1759 
1760 
1761 /// @brief string == Fstring
1762 bool
1763 operator ==( std::string const & t, Fstring const & s );
1764 
1765 
1766 /// @brief Fstring != string
1767 bool
1768 operator !=( Fstring const & s, std::string const & t );
1769 
1770 
1771 /// @brief string != Fstring
1772 bool
1773 operator !=( std::string const & t, Fstring const & s );
1774 
1775 
1776 /// @brief Fstring == cstring
1777 bool
1778 operator ==( Fstring const & s, c_cstring const t );
1779 
1780 
1781 /// @brief cstring == Fstring
1782 bool
1783 operator ==( c_cstring const t, Fstring const & s );
1784 
1785 
1786 /// @brief Fstring != cstring
1787 bool
1788 operator !=( Fstring const & s, c_cstring const t );
1789 
1790 
1791 /// @brief cstring != Fstring
1792 bool
1793 operator !=( c_cstring const t, Fstring const & s );
1794 
1795 
1796 /// @brief Fstring == char
1797 bool
1798 operator ==( Fstring const & s, char const c );
1799 
1800 
1801 /// @brief char == Fstring
1802 bool
1803 operator ==( char const c, Fstring const & s );
1804 
1805 
1806 /// @brief Fstring != char
1807 bool
1808 operator !=( Fstring const & s, char const c );
1809 
1810 
1811 /// @brief char != Fstring
1812 bool
1813 operator !=( char const c, Fstring const & s );
1814 
1815 
1816 /// @brief Fstring == Fstring Case-Insensitively?
1817 bool
1818 equali( Fstring const & s, Fstring const & t );
1819 
1820 
1821 /// @brief Fstring == string Case-Insensitively?
1822 bool
1823 equali( Fstring const & s, std::string const & t );
1824 
1825 
1826 /// @brief string == Fstring Case-Insensitively?
1827 bool
1828 equali( std::string const & s, Fstring const & t );
1829 
1830 
1831 /// @brief Fstring == char Case-Insensitively?
1832 bool
1833 equali( Fstring const & s, char const c );
1834 
1835 
1836 /// @brief char == Fstring Case-Insensitively?
1837 bool
1838 equali( char const c, Fstring const & s );
1839 
1840 
1841 /// @brief Fstring == Fstring Case-Optionally?
1842 bool
1843 equal( Fstring const & s, Fstring const & t, bool const exact_case );
1844 
1845 
1846 /// @brief Fstring == char Case-Optionally?
1847 bool
1848 equal( Fstring const & s, char const c, bool const exact_case );
1849 
1850 
1851 /// @brief char == Fstring Case-Optionally?
1852 bool
1853 equal( char const c, Fstring const & s, bool const exact_case );
1854 
1855 
1856 /// @brief Fstring <= Fstring
1857 bool
1858 operator <=( Fstring const & s, Fstring const & t );
1859 
1860 
1861 /// @brief Fstring < Fstring
1862 bool
1863 operator <( Fstring const & s, Fstring const & t );
1864 
1865 
1866 /// @brief Fstring >= Fstring
1867 bool
1868 operator >=( Fstring const & s, Fstring const & t );
1869 
1870 
1871 /// @brief Fstring > Fstring
1872 bool
1873 operator >( Fstring const & s, Fstring const & t );
1874 
1875 
1876 /// @brief Fstring <= string
1877 bool
1878 operator <=( Fstring const & s, std::string const & t );
1879 
1880 
1881 /// @brief Fstring < string
1882 bool
1883 operator <( Fstring const & s, std::string const & t );
1884 
1885 
1886 /// @brief Fstring >= string
1887 bool
1888 operator >=( Fstring const & s, std::string const & t );
1889 
1890 
1891 /// @brief Fstring > string
1892 bool
1893 operator >( Fstring const & s, std::string const & t );
1894 
1895 
1896 /// @brief string <= Fstring
1897 bool
1898 operator <=( std::string const & s, Fstring const & t );
1899 
1900 
1901 /// @brief string < Fstring
1902 bool
1903 operator <( std::string const & s, Fstring const & t );
1904 
1905 
1906 /// @brief string >= Fstring
1907 bool
1908 operator >=( std::string const & s, Fstring const & t );
1909 
1910 
1911 /// @brief string > Fstring
1912 bool
1913 operator >( std::string const & s, Fstring const & t );
1914 
1915 
1916 /// @brief Fstring <= cstring
1917 bool
1918 operator <=( Fstring const & s, c_cstring const t );
1919 
1920 
1921 /// @brief Fstring < cstring
1922 bool
1923 operator <( Fstring const & s, c_cstring const t );
1924 
1925 
1926 /// @brief Fstring >= cstring
1927 bool
1928 operator >=( Fstring const & s, c_cstring const t );
1929 
1930 
1931 /// @brief Fstring > cstring
1932 bool
1933 operator >( Fstring const & s, c_cstring const t );
1934 
1935 
1936 /// @brief cstring <= Fstring
1937 bool
1938 operator <=( c_cstring const s, Fstring const & t );
1939 
1940 
1941 /// @brief cstring < Fstring
1942 bool
1943 operator <( c_cstring const s, Fstring const & t );
1944 
1945 
1946 /// @brief cstring >= Fstring
1947 bool
1948 operator >=( c_cstring const s, Fstring const & t );
1949 
1950 
1951 /// @brief cstring > Fstring
1952 bool
1953 operator >( c_cstring const s, Fstring const & t );
1954 
1955 
1956 /// @brief Stream Input
1957 std::istream &
1958 operator >>( std::istream & stream, Fstring & s );
1959 
1960 
1961 /// @brief Get from Stream
1962 std::istream &
1963 get( std::istream & stream, Fstring & s );
1964 
1965 
1966 /// @brief Get Line from Stream
1967 std::istream &
1968 getline( std::istream & stream, Fstring & s );
1969 
1970 
1971 /// @brief Read from Stream
1972 std::istream &
1973 read( std::istream & stream, Fstring & s );
1974 
1975 
1976 /// @brief Read Available Characters from Stream
1977 std::istream &
1978 readsome( std::istream & stream, Fstring & s );
1979 
1980 
1981 /// @brief Stream Output
1982 std::ostream &
1983 operator <<( std::ostream & stream, Fstring const & s );
1984 
1985 
1986 // Fstring Member Function Explicit Specializations
1987 
1988 
1989  /// @brief Fstring is Readable as a char Supporting Stream Input?
1990  template<>
1991  inline
1992  bool
1994  {
1995  return ( size() == 1 );
1996  }
1997 
1998 
1999  /// @brief Fstring is Readable as a string Supporting Stream Input?
2000  template<>
2001  inline
2002  bool
2004  {
2005  return true;
2006  }
2007 
2008 
2009  /// @brief char of an Fstring
2010  template<>
2011  inline
2012  char
2014  {
2015  return ( len_ == 1 ? str_[ 0 ] : char() ); // Check is_type first
2016  }
2017 
2018 
2019  /// @brief string of an Fstring
2020  template<>
2021  inline
2022  std::string
2024  {
2025  return std::string( str_, len_ );
2026  }
2027 
2028 
2029 /// @brief Fsubstring: Fixed-Length Fortran-Compatible Substring
2030 ///
2031 /// @remarks
2032 /// @li Subscripts run from 1 to the length
2033 /// @li Space-padding is used in comparisons and assignments
2034 /// @li Internal string rep is not null-terminated
2035 /// @li Zero-length Fsubstrings are supported but cannot be indexed into (no valid indices)
2036 /// @li Fsubstring not for explicit use in client code: Client code uses Fstring::operator () to get substrings
2037 /// @li Pass s( i, j ).ref() to a non-const Fstring& argument
2038 /// @li Don't return a substring of a local as an Fsubstring since its copy ctor uses ref semantics: Return as an Fstring to get a copy
2039 class Fsubstring :
2040  public Fstring
2041 {
2042 
2043 
2044 private: // Types
2045 
2046 
2047  typedef Fstring Super;
2048 
2049 
2050  friend class Fstring;
2051 
2052 
2053 public: // Creation
2054 
2055 
2056  /// @brief Copy Constructor
2057  inline
2058  Fsubstring( Fsubstring const & s ) :
2059  Fstring( s, 1, s.len_ )
2060  {}
2061 
2062 
2063  /// @brief Destructor
2064  inline
2065  virtual
2067  {}
2068 
2069 
2070 private: // Creation
2071 
2072 
2073  /// @brief Fstring Range Constructor
2074  inline
2075  Fsubstring( Fstring const & s, size_type const i, size_type const j ) :
2076  Fstring( s, i, j )
2077  {}
2078 
2079 
2080  /// @brief Fstring Tail Constructor
2081  inline
2082  Fsubstring( Fstring const & s, size_type const i ) :
2083  Fstring( s, i )
2084  {}
2085 
2086 
2087 public: // Assignment
2088 
2089 
2090  /// @brief Copy Assignment
2091  Fsubstring &
2092  operator =( Fsubstring const & s );
2093 
2094 
2095  /// @brief = Fstring
2096  Fsubstring &
2097  operator =( Fstring const & s );
2098 
2099 
2100  /// @brief = string
2101  Fsubstring &
2102  operator =( std::string const & s );
2103 
2104 
2105  /// @brief = cstring
2106  Fsubstring &
2107  operator =( c_cstring const s );
2108 
2109 
2110  /// @brief = char
2111  Fsubstring &
2112  operator =( char const c );
2113 
2114 
2115 public: // Modifier
2116 
2117 
2118  /// @brief Reference to Fstring: Can Pass s( i, j ).ref() to an Fstring& Argument
2119  inline
2120  Fstring &
2122  {
2123  return *this;
2124  }
2125 
2126 
2127 }; // Fsubstring
2128 
2129 
2130 // Fortran-Intrinsic-Compatible String Functions
2131 
2132 
2133 namespace Fortran { // Control collision with Windows CHAR type and get Fstring, not char, output
2134 
2135 
2136 /// @brief One-Character Fstring of a Given ASCII Integer Value
2137 inline
2138 Fstring
2139 CHAR( int const i )
2140 {
2141  return Fstring( static_cast< char >( i ) );
2142 }
2143 
2144 
2145 /// @brief One-Character Fstring of a Given ASCII Integer Value
2146 inline
2147 Fstring
2148 ACHAR( int const i )
2149 {
2150  return Fstring( static_cast< char >( i ) );
2151 }
2152 
2153 
2154 } // namespace Fortran
2155 
2156 
2157 /// @brief Integer Value of a Given One-Character Fstring
2158 inline
2159 int
2160 ICHAR( Fstring const & s )
2161 {
2162  assert( s.length() == 1 );
2163  return static_cast< int >( s[ 1 ] );
2164 }
2165 
2166 
2167 /// @brief ASCII Integer Value of a Given One-Character Fstring
2168 inline
2169 int
2170 IACHAR( Fstring const & s )
2171 {
2172  assert( s.length() == 1 );
2173  return static_cast< int >( s[ 1 ] );
2174 }
2175 
2176 
2177 /// @brief First Index Position of a Substring in an Fstring
2178 inline
2180 index( Fstring const & s, Fstring const & ss )
2181 {
2182  return s.find( ss );
2183 }
2184 
2185 
2186 /// @brief First Index Position of a C-Substring in an Fstring
2187 inline
2189 index( Fstring const & s, c_cstring const ss )
2190 {
2191  return s.find( ss );
2192 }
2193 
2194 
2195 /// @brief First Index Position of a Character in an Fstring
2196 inline
2198 index( Fstring const & s, char const c )
2199 {
2200  return s.find( c );
2201 }
2202 
2203 
2204 /// @brief Length
2205 inline
2207 len( Fstring const & s )
2208 {
2209  return s.length();
2210 }
2211 
2212 
2213 /// @brief Length Space-Trimmed
2214 inline
2216 len_trim( Fstring const & s )
2217 {
2218  return s.len_trim();
2219 }
2220 
2221 
2222 /// @brief Space-Trimmed Copy
2223 inline
2224 Fstring
2225 trimmed( Fstring const & s )
2226 {
2227  return s.trimmed();
2228 }
2229 
2230 
2231 /// @brief ASCII Lexical >= Comparison
2232 inline
2233 bool
2234 lge( Fstring const & s, Fstring const & t )
2235 {
2236  return ( s >= t );
2237 }
2238 
2239 
2240 /// @brief ASCII Lexical < Comparison
2241 inline
2242 bool
2243 lgt( Fstring const & s, Fstring const & t )
2244 {
2245  return ( s > t );
2246 }
2247 
2248 
2249 /// @brief ASCII Lexical <= Comparison
2250 inline
2251 bool
2252 lle( Fstring const & s, Fstring const & t )
2253 {
2254  return ( s <= t );
2255 }
2256 
2257 
2258 /// @brief ASCII Lexical < Comparison
2259 inline
2260 bool
2261 llt( Fstring const & s, Fstring const & t )
2262 {
2263  return ( s < t );
2264 }
2265 
2266 
2267 // Fortran Migration Support String Functions
2268 
2269 
2270 // Predicate
2271 
2272 
2273 /// @brief Fstring is Blank?
2274 inline
2275 bool
2276 is_blank( Fstring const & s )
2277 {
2278  return s.is_blank();
2279 }
2280 
2281 
2282 /// @brief Fstring is Not Blank?
2283 inline
2284 bool
2285 not_blank( Fstring const & s )
2286 {
2287  return s.not_blank();
2288 }
2289 
2290 
2291 /// @brief Fstring Has Any Characters of a Set?
2292 inline
2293 bool
2294 has_any_of( Fstring const & s, Fstring const & t )
2295 {
2296  return s.has_any_of( t );
2297 }
2298 
2299 
2300 /// @brief Fstring Has Any Characters of a Set?
2301 inline
2302 bool
2303 has_any_of( Fstring const & s, c_cstring const t )
2304 {
2305  return s.has_any_of( t );
2306 }
2307 
2308 
2309 // Search
2310 
2311 
2312 /// @brief Last Index Position of a Substring in an Fstring
2313 inline
2315 last_index( Fstring const & s, Fstring const & ss )
2316 {
2317  return s.find_last( ss );
2318 }
2319 
2320 
2321 /// @brief Last Index Position of a Substring in an Fstring
2322 inline
2324 last_index( Fstring const & s, c_cstring const ss )
2325 {
2326  return s.find_last( ss );
2327 }
2328 
2329 
2330 /// @brief Last Index Position of a Character in an Fstring
2331 inline
2333 last_index( Fstring const & s, char const c )
2334 {
2335  return s.find_last( c );
2336 }
2337 
2338 
2339 // Modifier
2340 
2341 
2342 /// @brief Lowercase an Fstring
2343 inline
2344 Fstring &
2346 {
2347  return s.lowercase();
2348 }
2349 
2350 
2351 /// @brief Uppercase an Fstring
2352 inline
2353 Fstring &
2355 {
2356  return s.uppercase();
2357 }
2358 
2359 
2360 /// @brief Lowercase an Fstring
2361 inline
2362 void
2364 {
2365  s.lowercase();
2366 }
2367 
2368 
2369 /// @brief Uppercase an Fstring
2370 inline
2371 void
2373 {
2374  s.uppercase();
2375 }
2376 
2377 
2378 /// @brief Lowercased Copy in an Output Fstring
2379 inline
2380 void
2381 str_dncase( Fstring & s_out, Fstring const & s_in )
2382 {
2383  s_out = s_in;
2384  s_out.lowercase();
2385 }
2386 
2387 
2388 /// @brief Uppercased Copy in an Output Fstring
2389 inline
2390 void
2391 str_upcase( Fstring & s_out, Fstring const & s_in )
2392 {
2393  s_out = s_in;
2394  s_out.uppercase();
2395 }
2396 
2397 
2398 // Generator
2399 
2400 
2401 /// @brief Left-Justified Copy
2402 inline
2403 Fstring
2404 ljust( Fstring const & s )
2405 {
2406  return s.left_justified();
2407 }
2408 
2409 
2410 /// @brief Right-Justified Copy
2411 inline
2412 Fstring
2413 rjust( Fstring const & s )
2414 {
2415  return s.right_justified();
2416 }
2417 
2418 
2419 /// @brief Compressed Copy
2420 inline
2421 Fstring
2422 compress( Fstring const & s )
2423 {
2424  return s.compressed();
2425 }
2426 
2427 
2428 /// @brief Centered Copy
2429 inline
2430 Fstring
2431 center( Fstring const & s )
2432 {
2433  return s.centered();
2434 }
2435 
2436 
2437 /// @brief Lowercased Copy
2438 inline
2439 Fstring
2441 {
2442  return s.lowercased();
2443 }
2444 
2445 
2446 /// @brief Uppercased Copy
2447 inline
2448 Fstring
2450 {
2451  return s.uppercased();
2452 }
2453 
2454 
2455 /// @brief Lowercased Copy
2456 inline
2457 Fstring
2458 dncase( Fstring const & s )
2459 {
2460  return s.lowercased();
2461 }
2462 
2463 
2464 /// @brief Uppercased Copy
2465 inline
2466 Fstring
2467 upcase( Fstring const & s )
2468 {
2469  return s.uppercased();
2470 }
2471 
2472 
2473 // Conversion To Fstring
2474 
2475 
2476 /// @brief Fstring of a Template Argument Type Supporting Stream Output
2477 template< typename T >
2478 inline
2479 Fstring
2480 Fstring_of( T const & t )
2481 {
2482  std::ostringstream t_stream;
2483  t_stream << std::uppercase << std::setprecision( TypeTraits< T >::precision() ) << t;
2484  return t_stream.str();
2485 }
2486 
2487 
2488 /// @brief Fstring of a string Specialization
2489 template<>
2490 inline
2491 Fstring
2492 Fstring_of< std::string >( std::string const & t )
2493 {
2494  return Fstring( t );
2495 }
2496 
2497 
2498 /// @brief Fstring of a Template Argument Type Supporting Stream Output
2499 template< typename T >
2500 inline
2501 Fstring
2503  T const & t,
2504  int const p // Precision
2505 )
2506 {
2507  std::ostringstream t_stream;
2508  t_stream << std::uppercase << std::setprecision( p ) << t;
2509  return t_stream.str();
2510 }
2511 
2512 
2513 /// @brief Left-Justified Fstring of a Template Argument Type Supporting Stream Output
2514 template< typename T >
2515 inline
2516 Fstring
2518  T const & t,
2519  int const w, // Minimum width
2520  char const f = ' ' // Fill character
2521 )
2522 {
2523  std::ostringstream t_stream;
2524  t_stream << std::left << std::uppercase
2525  << std::setw( w ) << std::setfill( f ) << std::setprecision( TypeTraits< T >::precision() ) << t;
2526  return t_stream.str();
2527 }
2528 
2529 
2530 /// @brief Right-Justified Fstring of a Template Argument Type Supporting Stream Output
2531 template< typename T >
2532 inline
2533 Fstring
2535  T const & t,
2536  int const w, // Minimum width
2537  char const f = ' ' // Fill character
2538 )
2539 {
2540  std::ostringstream t_stream;
2541  t_stream << std::right << std::uppercase
2542  << std::setw( w ) << std::setfill( f ) << std::setprecision( TypeTraits< T >::precision() ) << t;
2543  return t_stream.str();
2544 }
2545 
2546 
2547 /// @brief Leading-Zero Right-Justified Fstring of a Template Argument Type Supporting Stream Output
2548 /// @note Negative numbers appear with the minus sign on the left of the filled zeros
2549 template< typename T >
2550 inline
2551 Fstring
2553  T const & t,
2554  int const w // Minimum width
2555 )
2556 {
2557  std::ostringstream t_stream;
2558  t_stream << std::internal << std::uppercase
2559  << std::setw( w ) << std::setfill( '0' ) << std::setprecision( TypeTraits< T >::precision() ) << t;
2560  return t_stream.str();
2561 }
2562 
2563 
2564 /// @brief Right-Justified General Format Fstring of a Template Argument Type Supporting Stream Output
2565 template< typename T >
2566 inline
2567 Fstring
2569  T const & t,
2570  int const w = TypeTraits< T >::width(), // Minimum width
2571  int const p = TypeTraits< T >::precision() // Precision
2572 )
2573 {
2574  std::ostringstream t_stream;
2575  t_stream << std::right << std::uppercase << std::showpoint
2576  << std::setw( w ) << std::setprecision( p ) << t;
2577  return t_stream.str();
2578 }
2579 
2580 
2581 /// @brief Right-Justified Fixed Format Fstring of a Template Argument Type Supporting Stream Output
2582 template< typename T >
2583 inline
2584 Fstring
2586  T const & t,
2587  int const w = TypeTraits< T >::width(), // Minimum width
2588  int const p = TypeTraits< T >::precision() // Precision
2589 )
2590 {
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();
2595 }
2596 
2597 
2598 /// @brief Right-Justified Scientific Format Fstring of a Template Argument Type Supporting Stream Output
2599 template< typename T >
2600 inline
2601 Fstring
2603  T const & t,
2604  int const w = TypeTraits< T >::width(), // Minimum width
2605  int const p = TypeTraits< T >::precision() // Precision
2606 )
2607 {
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();
2612 }
2613 
2614 
2615 // Conversion From Fstring
2616 
2617 
2618 /// @brief Fstring is Readable as a Type Supporting Stream Input?
2619 template< typename T >
2620 inline
2621 bool
2622 is_type( Fstring const & s )
2623 {
2624  if ( s.is_blank() ) { // Don't accept blank Fstring
2625  return false;
2626  } else { // Try to read the Fstring as a T
2627  std::istringstream t_stream( s.trimmed_whitespace() );
2628  T t;
2629  t_stream >> t;
2630  return ( ( t_stream ) && ( t_stream.eof() ) );
2631  }
2632 }
2633 
2634 
2635 /// @brief Fstring is Readable as a string Supporting Stream Input?
2636 template<>
2637 inline
2638 bool
2640 {
2641  return true;
2642 }
2643 
2644 
2645 /// @brief Fstring is Readable as a char Supporting Stream Input?
2646 template<>
2647 inline
2648 bool
2650 {
2651  return ( s.size() == 1 );
2652 }
2653 
2654 
2655 /// @brief Fstring is Readable as a bool?
2656 inline
2657 bool
2658 is_bool( Fstring const & s )
2659 {
2660  return is_type< bool >( s );
2661 }
2662 
2663 
2664 /// @brief Fstring is Readable as a short int?
2665 inline
2666 bool
2667 is_short( Fstring const & s )
2668 {
2669  return is_type< short int >( s );
2670 }
2671 
2672 
2673 /// @brief Fstring is Readable as an int?
2674 inline
2675 bool
2676 is_int( Fstring const & s )
2677 {
2678  return is_type< int >( s );
2679 }
2680 
2681 
2682 /// @brief Fstring is Readable as a long int?
2683 inline
2684 bool
2685 is_long( Fstring const & s )
2686 {
2687  return is_type< long int >( s );
2688 }
2689 
2690 
2691 /// @brief Fstring is Readable as a unsigned short int?
2692 inline
2693 bool
2694 is_ushort( Fstring const & s )
2695 {
2696  return is_type< unsigned short int >( s );
2697 }
2698 
2699 
2700 /// @brief Fstring is Readable as an unsigned int?
2701 inline
2702 bool
2703 is_uint( Fstring const & s )
2704 {
2705  return is_type< unsigned int >( s );
2706 }
2707 
2708 
2709 /// @brief Fstring is Readable as a unsigned long int?
2710 inline
2711 bool
2712 is_ulong( Fstring const & s )
2713 {
2714  return is_type< unsigned long int >( s );
2715 }
2716 
2717 
2718 /// @brief Fstring is Readable as a float?
2719 inline
2720 bool
2721 is_float( Fstring const & s )
2722 {
2723  return is_type< float >( s );
2724 }
2725 
2726 
2727 /// @brief Fstring is Readable as a double?
2728 inline
2729 bool
2730 is_double( Fstring const & s )
2731 {
2732  return is_type< double >( s );
2733 }
2734 
2735 
2736 /// @brief Fstring is Readable as a long double?
2737 inline
2738 bool
2740 {
2741  return is_type< long double >( s );
2742 }
2743 
2744 
2745 /// @brief Fstring is Readable as a char?
2746 inline
2747 bool
2748 is_char( Fstring const & s )
2749 {
2750  return is_type< char >( s );
2751 }
2752 
2753 
2754 /// @brief Fstring is Readable as a string?
2755 inline
2756 bool
2757 is_string( Fstring const & )
2758 {
2759  return true;
2760 }
2761 
2762 
2763 /// @brief Type of an Fstring for Type Supporting Stream Input
2764 template< typename T >
2765 inline
2766 T
2767 type_of( Fstring const & s )
2768 {
2769  std::istringstream t_stream( s.trimmed_whitespace() );
2770  T t;
2771  t_stream >> t;
2772  return ( ( t_stream ) && ( t_stream.eof() ) ? t : T() ); // Check is_type first
2773 }
2774 
2775 
2776 /// @brief string of an Fstring
2777 template<>
2778 inline
2779 std::string
2781 {
2782  return std::string( s );
2783 }
2784 
2785 
2786 /// @brief char of an Fstring
2787 template<>
2788 inline
2789 char
2791 {
2792  return ( s.size() == 1 ? s[ 0 ] : char() ); // Check is_type first
2793 }
2794 
2795 
2796 /// @brief short int of an Fstring
2797 inline
2798 short int
2799 short_of( Fstring const & s )
2800 {
2801  return type_of< short int >( s );
2802 }
2803 
2804 
2805 /// @brief int of an Fstring
2806 inline
2807 int
2808 int_of( Fstring const & s )
2809 {
2810  return type_of< int >( s );
2811 }
2812 
2813 
2814 /// @brief long int of an Fstring
2815 inline
2816 long int
2817 long_of( Fstring const & s )
2818 {
2819  return type_of< long int >( s );
2820 }
2821 
2822 
2823 /// @brief unsigned short int of an Fstring
2824 inline
2825 unsigned short int
2826 ushort_of( Fstring const & s )
2827 {
2828  return type_of< unsigned short int >( s );
2829 }
2830 
2831 
2832 /// @brief unsigned int of an Fstring
2833 inline
2834 unsigned int
2835 uint_of( Fstring const & s )
2836 {
2837  return type_of< unsigned int >( s );
2838 }
2839 
2840 
2841 /// @brief unsigned long int of an Fstring
2842 inline
2843 unsigned long int
2844 ulong_of( Fstring const & s )
2845 {
2846  return type_of< unsigned long int >( s );
2847 }
2848 
2849 
2850 /// @brief float of an Fstring
2851 inline
2852 float
2853 float_of( Fstring const & s )
2854 {
2855  return type_of< float >( s );
2856 }
2857 
2858 
2859 /// @brief double of an Fstring
2860 inline
2861 double
2862 double_of( Fstring const & s )
2863 {
2864  return type_of< double >( s );
2865 }
2866 
2867 
2868 /// @brief long double of an Fstring
2869 inline
2870 long double
2872 {
2873  return type_of< long double >( s );
2874 }
2875 
2876 
2877 /// @brief char of an Fstring
2878 inline
2879 char
2880 char_of( Fstring const & s )
2881 {
2882  return type_of< char >( s );
2883 }
2884 
2885 
2886 /// @brief string of an Fstring
2887 inline
2888 std::string
2889 string_of( Fstring const & s )
2890 {
2891  return std::string( s );
2892 }
2893 
2894 
2895 } // namespace ObjexxFCL
2896 
2897 
2898 #endif // INCLUDED_ObjexxFCL_Fstring_HH
std::istream & operator>>(std::istream &stream, byte &b)
Stream Input.
Definition: byte.hh:409
bool is_string(Fstring const &)
Fstring is Readable as a string?
Definition: Fstring.hh:2757
friend bool operator>(Fstring const &s, Fstring const &t)
Fstring > Fstring.
Definition: Fstring.hh:1458
friend bool operator==(Fstring const &s, Fstring const &t)
Fstring == Fstring.
Definition: Fstring.cc:1204
bool not_blank(char const c)
Character is Not Blank?
size_type len_
Length.
Definition: Fstring.hh:1694
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.
Definition: Fstring.hh:2458
char lowercased(char const c)
Lowercased Copy of a Character.
bool operator!=(byte const &i, byte const &j)
byte != byte
Definition: byte.hh:356
Fstring compress(Fstring const &s)
Compressed Copy.
Definition: Fstring.hh:2422
unsigned long int ulong_of(Fstring const &s)
unsigned long int of an Fstring
Definition: Fstring.hh:2844
Fstring & right_justify()
Right Justify.
Definition: Fstring.cc:908
Fstring & center()
Center.
Definition: Fstring.cc:925
Fstring lead_zero_Fstring_of(T const &t, int const w)
Leading-Zero Right-Justified Fstring of a Template Argument Type Supporting Stream Output...
Definition: Fstring.hh:2552
void str_dncase(Fstring &s_out, Fstring const &s_in)
Lowercased Copy in an Output Fstring.
Definition: Fstring.hh:2381
Fstring right_justified() const
Right-Justified Copy.
Definition: Fstring.hh:931
size_type find_last_whitespace() const
Find Last Occurrence of a Whitespace Character.
Definition: Fstring.cc:491
T type_of(Fstring const &s)
Type of an Fstring for Type Supporting Stream Input.
Definition: Fstring.hh:2767
Fstring lowercased() const
Lowercased Copy.
Definition: Fstring.hh:958
bool is_short(Fstring const &s)
Fstring is Readable as a short int?
Definition: Fstring.hh:2667
Fstring stripped() const
Space Stripped from Tails Copy.
Definition: Fstring.hh:1031
size_type copy(cstring str, size_type const len_a, size_type const off=0) const
Copy to a Pre-Allocated String.
Definition: Fstring.cc:1193
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...
Definition: Fstring.hh:2602
friend std::istream & getline(std::istream &stream, Fstring &s)
Get Line from Stream.
Definition: Fstring.cc:1610
bool is_blank(char const c)
Character is Blank?
bool operator>=(byte const &i, byte const &j)
byte >= byte
Definition: byte.hh:396
long double longdouble_of() const
long double of the Fstring
Definition: Fstring.hh:774
bool is_char() const
Fstring is Readable as a char?
Definition: Fstring.hh:484
std::string Fstring::type_of< std::string >() const
string of an Fstring
Definition: Fstring.hh:2023
std::istream & read(std::istream &stream, Fstring &s)
Read from Stream.
Definition: Fstring.cc:1622
unsigned short int ushort_of(Fstring const &s)
unsigned short int of an Fstring
Definition: Fstring.hh:2826
Fstring & rstrip()
Strip Space from an Fstring's Right Tail.
Definition: Fstring.cc:1068
bool is_short() const
Fstring is Readable as a short int?
Definition: Fstring.hh:403
std::istream & getline(std::istream &stream, Fstring &s)
Get Line from Stream.
Definition: Fstring.cc:1610
bool equal(Fstring const &s, Fstring const &t, bool const exact_case=true)
Fstring == Fstring Case-Optionally?
Definition: Fstring.hh:1396
friend bool operator<=(Fstring const &s, Fstring const &t)
Fstring <= Fstring.
Definition: Fstring.cc:1283
cmplx w(cmplx z, double relerr)
Definition: functions.cc:470
Fstring & rstrip_whitespace()
Strip Whitespace from an Fstring's Right Tail.
Definition: Fstring.cc:1126
char * cstring
Definition: Cstring.hh:35
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.
Definition: Fstring.cc:467
size_type len() const
Length.
Definition: Fstring.hh:523
bool not_whitespace() const
Not whitespace?
Definition: Fstring.hh:316
unsigned short int ushort_of() const
unsigned short int of the Fstring
Definition: Fstring.hh:729
friend std::istream & read(std::istream &stream, Fstring &s)
Read from Stream.
Definition: Fstring.cc:1622
T type_of() const
Type of an Fstring for Type Supporting Stream Input.
Definition: Fstring.hh:688
bool is_bool(Fstring const &s)
Fstring is Readable as a bool?
Definition: Fstring.hh:2658
char * c_str_
cstring
Definition: Fstring.hh:1700
Fstring Fstring_of(T const &t)
Fstring of a Template Argument Type Supporting Stream Output.
Definition: Fstring.hh:2480
Fsubstring(Fstring const &s, size_type const i, size_type const j)
Fstring Range Constructor.
Definition: Fstring.hh:2075
bool operator<=(byte const &i, byte const &j)
byte <= byte
Definition: byte.hh:376
Fstring & overlay(Fstring const &s, size_type const pos=1)
Overlay an Fstring.
Definition: Fstring.cc:1142
Fstring left_justified() const
Left-Justified Copy.
Definition: Fstring.hh:922
char operator[](size_type const i) const
Constant char: s[ i ].
Definition: Fstring.hh:255
Fstring stripped(std::string const &chars) const
Specified Characters Stripped from Tails Copy.
Definition: Fstring.hh:994
void(* InitializerFunction)(Fstring &)
Definition: Fstring.hh:71
bool is_uint() const
Fstring is Readable as an unsigned int?
Definition: Fstring.hh:439
c_cstring c_str() const
Null-Terminated cstring Copy of the Fstring that is Owned by the Fstring.
Definition: Fstring.cc:1169
bool is_blank() const
Blank?
Definition: Fstring.hh:289
size_type find_last(Fstring const &s) const
Find Last Occurrence of an Fstring.
Definition: Fstring.cc:578
Fstring & strip_whitespace()
Strip Whitespace from an Fstring's Tails.
Definition: Fstring.cc:1084
char type_of< char >(Fstring const &s)
char of an Fstring
Definition: Fstring.hh:2790
size_type find_last_not_of(Fstring const &s) const
Find Last Occurrence of Any Character not of an Fstring.
Definition: Fstring.cc:802
Fsubstring & operator=(Fsubstring const &s)
Copy Assignment.
Definition: Fstring.cc:1655
bool has_any_of(Fstring const &s) const
Has Any Character of an Fstring?
Definition: Fstring.cc:359
bool is_string() const
Fstring is Readable as a string?
Definition: Fstring.hh:493
char & lowercase(char &c)
Lowercase a Character.
std::size_t size_type
Definition: Fstring.hh:66
size_type len_trim() const
Length Space-Trimmed.
Definition: Fstring.cc:444
TypeTraits: Type Traits Template.
Definition: TypeTraits.hh:23
bool is_longdouble(Fstring const &s)
Fstring is Readable as a long double?
Definition: Fstring.hh:2739
bool is_double() const
Fstring is Readable as a double?
Definition: Fstring.hh:466
long double longdouble_of(Fstring const &s)
long double of an Fstring
Definition: Fstring.hh:2871
Fstring & compress()
Compress Out Whitespace.
Definition: Fstring.cc:940
Fstring rstripped() const
Space Stripped from Right Tail Copy.
Definition: Fstring.hh:1059
Fsubstring: Fixed-Length Fortran-Compatible Substring.
Definition: Fstring.hh:2039
friend bool operator>=(Fstring const &s, Fstring const &t)
Fstring >= Fstring.
Definition: Fstring.hh:1448
Fstring lstripped() const
Space Stripped from Left Tail Copy.
Definition: Fstring.hh:1045
byte operator+(byte const &i, byte const &j)
byte + byte
Definition: byte.hh:194
Fstring::size_type len(Fstring const &s)
Length.
Definition: Fstring.hh:2207
Fstring::size_type index(Fstring const &s, Fstring const &ss)
First Index Position of a Substring in an Fstring.
Definition: Fstring.hh:2180
Fstring compressed() const
Compressed Copy.
Definition: Fstring.hh:949
bool lgt(char const s, char const t)
ASCII Lexical < Comparison.
bool is_longdouble() const
Fstring is Readable as a long double?
Definition: Fstring.hh:475
bool equal(char const c, Fstring const &s, bool const exact_case=true)
char == Fstring Case-Optionally?
Definition: Fstring.hh:1422
size_type find_first_of(Fstring const &s) const
Find First Occurrence of Any Character of an Fstring.
Definition: Fstring.cc:631
virtual ~Fsubstring()
Destructor.
Definition: Fstring.hh:2066
bool equal(Fstring const &s, char const c, bool const exact_case=true)
Fstring == char Case-Optionally?
Definition: Fstring.hh:1409
Fsubstring(Fsubstring const &s)
Copy Constructor.
Definition: Fstring.hh:2058
bool is_char(Fstring const &s)
Fstring is Readable as a char?
Definition: Fstring.hh:2748
std::string type_of< std::string >(Fstring const &s)
string of an Fstring
Definition: Fstring.hh:2780
char const * c_cstring
c_cstring t_str() const
Whitespace-Trimmed Null-Terminated cstring Copy of the Fstring that is Owned by the Fstring...
Definition: Fstring.cc:1181
std::string string_of() const
string of the Fstring
Definition: Fstring.hh:792
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.
Definition: Fstring.cc:525
size_type size() const
Size.
Definition: Fstring.hh:505
Fstring::size_type last_index(Fstring const &s, Fstring const &ss)
Last Index Position of a Substring in an Fstring.
Definition: Fstring.hh:2315
long int long_of(Fstring const &s)
long int of an Fstring
Definition: Fstring.hh:2817
bool is_uint(Fstring const &s)
Fstring is Readable as an unsigned int?
Definition: Fstring.hh:2703
size_type find_first_not_of(Fstring const &s) const
Find First Occurrence of Any Character not of an Fstring.
Definition: Fstring.cc:683
Fstring rstripped(std::string const &chars) const
Specified Characters Stripped from Right Tail Copy.
Definition: Fstring.hh:1022
tuple p
Definition: docking.py:9
Fstring uppercased() const
Uppercased Copy.
Definition: Fstring.hh:967
std::istream & readsome(std::istream &stream, Fstring &s)
Read Available Characters from Stream.
Definition: Fstring.cc:1631
bool const sub_
Substring flag.
Definition: Fstring.hh:1703
bool has_prefix(Fstring const &s, bool const exact_case=true) const
Has a Prefix Case-Optionally?
Definition: Fstring.cc:411
Fstring & lstrip()
Strip Space from an Fstring's Left Tail.
Definition: Fstring.cc:1048
bool is_int() const
Fstring is Readable as an int?
Definition: Fstring.hh:412
Fstring(char const c)
char Constructor
Definition: Fstring.hh:102
size_type find_last_non_whitespace() const
Find Last Occurrence of a Non-Whitespace Character.
Definition: Fstring.cc:503
void(* initializer_function)(Fstring &)
Definition: Fstring.hh:67
c_cstring data() const
Non-Null-Terminated cstring Copy of the Fstring Data.
Definition: Fstring.hh:1115
Fstring & operator=(Fstring const &s)
Copy Assignment.
Definition: Fstring.cc:241
Fstring & ref()
Reference to Fstring: Can Pass s( i, j ).ref() to an Fstring& Argument.
Definition: Fstring.hh:2121
Fsubstring tail()
Space Tail Substring.
Definition: Fstring.cc:1575
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?
Definition: Fstring.hh:430
Fstring upcase(Fstring const &s)
Uppercased Copy.
Definition: Fstring.hh:2467
Fstring & clear()
Clear.
Definition: Fstring.hh:894
friend class Fsubstring
Definition: Fstring.hh:60
Fstring::size_type len_trim(Fstring const &s)
Length Space-Trimmed.
Definition: Fstring.hh:2216
Fstring rstripped_whitespace() const
Whitespace Stripped from Right Tail Copy.
Definition: Fstring.hh:1096
Fstring & uppercase(Fstring &s)
Uppercase an Fstring.
Definition: Fstring.hh:2354
bool has(Fstring const &s) const
Has an Fstring?
Definition: Fstring.cc:315
size_type find_non_whitespace() const
Find First Occurrence of a Non-Whitespace Character.
Definition: Fstring.cc:479
friend std::ostream & operator<<(std::ostream &stream, Fstring const &s)
Stream Output.
Definition: Fstring.cc:1640
bool empty() const
Empty?
Definition: Fstring.hh:280
Fstring & trim_whitespace()
Trim Trailing Whitespace Replacing it with Space.
Definition: Fstring.cc:954
friend std::istream & operator>>(std::istream &stream, Fstring &s)
Stream Input.
Definition: Fstring.cc:1583
virtual ~Fstring()
Destructor.
Definition: Fstring.hh:197
Fstring & lstrip_whitespace()
Strip Whitespace from an Fstring's Left Tail.
Definition: Fstring.cc:1106
double double_of() const
double of the Fstring
Definition: Fstring.hh:765
size_type find_last_of(Fstring const &s) const
Find Last Occurrence of Any Character of an Fstring.
Definition: Fstring.cc:750
char char_of() const
char of the Fstring
Definition: Fstring.hh:783
Fstring centered() const
Centered Copy.
Definition: Fstring.hh:940
bool is_type< char >(Fstring const &s)
Fstring is Readable as a char Supporting Stream Input?
Definition: Fstring.hh:2649
friend bool operator<(Fstring const &s, Fstring const &t)
Fstring < Fstring.
Definition: Fstring.cc:1320
size_type length() const
Length.
Definition: Fstring.hh:514
bool is_ushort(Fstring const &s)
Fstring is Readable as a unsigned short int?
Definition: Fstring.hh:2694
Fsubstring(Fstring const &s, size_type const i)
Fstring Tail Constructor.
Definition: Fstring.hh:2082
bool is_type(Fstring const &s)
Fstring is Readable as a Type Supporting Stream Input?
Definition: Fstring.hh:2622
bool is_long() const
Fstring is Readable as a long int?
Definition: Fstring.hh:421
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
Definition: Fstring.hh:2835
friend std::istream & readsome(std::istream &stream, Fstring &s)
Read Available Characters from Stream.
Definition: Fstring.cc:1631
bool is_int(Fstring const &s)
Fstring is Readable as an int?
Definition: Fstring.hh:2676
float float_of(Fstring const &s)
float of an Fstring
Definition: Fstring.hh:2853
Fstring(signed char const c)
signed char Constructor
Definition: Fstring.hh:115
Fstring ACHAR(int const i)
One-Character Fstring of a Given ASCII Integer Value.
Definition: Fstring.hh:2148
Fstring(unsigned char const c)
unsigned char Constructor
Definition: Fstring.hh:128
friend bool operator!=(Fstring const &s, Fstring const &t)
Fstring != Fstring.
Definition: Fstring.hh:1229
Fstring & trim()
Trim Trailing Space.
Definition: Fstring.hh:835
Fstring & left_justify()
Left Justify.
Definition: Fstring.cc:891
Fstring ljust(Fstring const &s)
Left-Justified Copy.
Definition: Fstring.hh:2404
Fstring lstripped_whitespace() const
Whitespace Stripped from Left Tail Copy.
Definition: Fstring.hh:1082
Fstring lstripped(std::string const &chars) const
Specified Characters Stripped from Left Tail Copy.
Definition: Fstring.hh:1008
bool operator>(byte const &i, byte const &j)
byte > byte
Definition: byte.hh:386
Fstring left_Fstring_of(T const &t, int const w, char const f= ' ')
Left-Justified Fstring of a Template Argument Type Supporting Stream Output.
Definition: Fstring.hh:2517
bool is_long(Fstring const &s)
Fstring is Readable as a long int?
Definition: Fstring.hh:2685
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...
Definition: Fstring.hh:2585
Fstring center(Fstring const &s)
Centered Copy.
Definition: Fstring.hh:2431
Fsubstring const operator()(size_type const i, size_type const j) const
Constant Substring: s( i, j )
Definition: Fstring.cc:1509
float float_of() const
float of the Fstring
Definition: Fstring.hh:756
int int_of() const
int of the Fstring
Definition: Fstring.hh:711
void str_upcase(Fstring &s_out, Fstring const &s_in)
Uppercased Copy in an Output Fstring.
Definition: Fstring.hh:2391
int int_of(Fstring const &s)
int of an Fstring
Definition: Fstring.hh:2808
bool has_any_of(Fstring const &s, Fstring const &t)
Fstring Has Any Characters of a Set?
Definition: Fstring.hh:2294
bool Fstring::is_type< std::string >() const
Fstring is Readable as a string Supporting Stream Input?
Definition: Fstring.hh:2003
Fstring right_Fstring_of(T const &t, int const w, char const f= ' ')
Right-Justified Fstring of a Template Argument Type Supporting Stream Output.
Definition: Fstring.hh:2534
bool llt(char const s, char const t)
ASCII Lexical < Comparison.
Fstring: Fixed-Length Fortran-Compatible String.
Definition: Fstring.hh:53
bool operator<(byte const &i, byte const &j)
byte < byte
Definition: byte.hh:366
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...
Definition: Fstring.hh:2568
Fstring trimmed(Fstring const &s)
Space-Trimmed Copy.
Definition: Fstring.hh:2225
std::string string_of(Fstring const &s)
string of an Fstring
Definition: Fstring.hh:2889
bool is_ulong(Fstring const &s)
Fstring is Readable as a unsigned long int?
Definition: Fstring.hh:2712
friend bool equali(Fstring const &s, Fstring const &t)
Fstring == Fstring Case-Insensitively?
Definition: Fstring.hh:1347
unsigned long int ulong_of() const
unsigned long int of the Fstring
Definition: Fstring.hh:747
void init()
set global 'init_was_called' to true
Definition: init.cc:26
bool is_whitespace() const
Whitespace?
Definition: Fstring.hh:307
Fstring rjust(Fstring const &s)
Right-Justified Copy.
Definition: Fstring.hh:2413
void str_dn(Fstring &s)
Lowercase an Fstring.
Definition: Fstring.hh:2363
void str_up(Fstring &s)
Uppercase an Fstring.
Definition: Fstring.hh:2372
Fstring()
Default Constructor.
Definition: Fstring.hh:79
Fstring CHAR(int const i)
One-Character Fstring of a Given ASCII Integer Value.
Definition: Fstring.hh:2139
std::ostream & operator<<(std::ostream &stream, CArray< T > const &a)
stream << CArray
Definition: CArray.io.hh:33
bool not_blank() const
Not blank?
Definition: Fstring.hh:298
bool is_ulong() const
Fstring is Readable as a unsigned long int?
Definition: Fstring.hh:448
Fstring & uppercase()
Uppercase.
Definition: Fstring.cc:880
std::size_t Size
Definition: Fstring.hh:70
bool operator==(byte const &i, byte const &j)
byte == byte
Definition: byte.hh:346
Fstring & lowercase()
Lowercase.
Definition: Fstring.cc:869
Fstring trimmed_whitespace() const
Trailing Whitespace Trimmed Copy.
Definition: Fstring.hh:985
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
Definition: Fstring.hh:720
char & uppercase(char &c)
Uppercase a Character.
Fstring Fstring_of< std::string >(std::string const &t)
Fstring of a string Specialization.
Definition: Fstring.hh:2492
char char_of(Fstring const &s)
char of an Fstring
Definition: Fstring.hh:2880
bool is_bool() const
Fstring is Readable as a bool?
Definition: Fstring.hh:394
Fsubstring const head() const
Space-Free Head Constant Substring.
Definition: Fstring.cc:1541
Fstring trimmed() const
Trailing Space Trimmed Copy.
Definition: Fstring.hh:976
bool is_type() const
Fstring is Readable as a Type Supporting Stream Input?
Definition: Fstring.hh:376
Fstring & strip()
Strip Space from an Fstring's Tails.
Definition: Fstring.cc:1026
char * str_
String.
Definition: Fstring.hh:1697
bool lle(char const s, char const t)
ASCII Lexical <= Comparison.
double double_of(Fstring const &s)
double of an Fstring
Definition: Fstring.hh:2862
bool is_double(Fstring const &s)
Fstring is Readable as a double?
Definition: Fstring.hh:2730
friend Fstring operator+(Fstring const &s, Fstring const &t)
Fstring + Fstring.
Definition: Fstring.hh:1133
short int short_of(Fstring const &s)
short int of an Fstring
Definition: Fstring.hh:2799
size_type trimmed_whitespace_range(size_type &b, size_type &e) const
Get Range of Whitespace-Trimmed Portion and Return its Length.
Definition: Fstring.cc:515
bool is_float(Fstring const &s)
Fstring is Readable as a float?
Definition: Fstring.hh:2721
unsigned int uint_of() const
unsigned int of the Fstring
Definition: Fstring.hh:738
Fstring stripped_whitespace() const
Whitespace Stripped from Tails Copy.
Definition: Fstring.hh:1068
bool is_float() const
Fstring is Readable as a float?
Definition: Fstring.hh:457
bool is_type< std::string >(Fstring const &)
Fstring is Readable as a string Supporting Stream Input?
Definition: Fstring.hh:2639
short int short_of() const
short int of the Fstring
Definition: Fstring.hh:702
size_type len_trim_whitespace() const
Length Whitespace-Trimmed.
Definition: Fstring.cc:455