Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
format.hh
Go to the documentation of this file.
1 #ifndef INCLUDED_ObjexxFCL_format_hh
2 #define INCLUDED_ObjexxFCL_format_hh
3 
4 
5 // Fortran-Compatible Formatted Input/Output Support
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/byte.fwd.hh>
20 #include <ObjexxFCL/ubyte.fwd.hh>
21 #include <ObjexxFCL/Fstring.fwd.hh>
23 
24 // C++ Headers
25 #include <algorithm>
26 #include <cmath>
27 #include <complex>
28 #include <iomanip>
29 //#include <iosfwd>
30 //#include <istream>
31 #include <limits>
32 #include <sstream>
33 #include <string>
34 
35 
36 namespace ObjexxFCL {
37 namespace format {
38 
39 
40 // Constants
41 char const SPACE( ' ' );
42 
43 
44 // Types
45 typedef char * cstring;
46 typedef char const * c_cstring;
47 
48 
49 // Formatted Input
50 
51 
52 // Bite: Inputs a String of Given Width from the Input Stream into a Value
53 template< typename T >
54 class Bite
55 {
56 
57 
58 public: // Creation
59 
60 
61  /// @brief Width + Value Constructor
62  inline
63  Bite( int const w, T & t ) :
64  w_( w ),
65  d_( 0 ),
66  t_( t )
67  {}
68 
69 
70  /// @brief Width + Precision + Value Constructor
71  inline
72  Bite( int const w, int const d, T & t ) :
73  w_( w ),
74  d_( d ), // In Fortran d>=0 but that is not enforced here
75  t_( t )
76  {}
77 
78 
79  /// @brief Destructor
80  inline
82  {}
83 
84 
85 public: // I/O
86 
87 
88  /// @brief Input a Bite from Stream
89  friend
90  inline
91  std::istream &
92  operator >>( std::istream & stream, Bite const & bite )
93  {
94  std::stringstream ss;
95  char c;
96  int i( 0 );
97  while ( ( i < bite.w_ ) && ( stream ) && ( stream.peek() != '\n' ) ) {
98  stream.get( c );
99  if ( stream ) ss << c;
100  ++i;
101  }
102  bite.assign( ss );
103  stream.setstate( stream.rdstate() | ( ss.rdstate() & ~std::ios_base::eofbit ) );
104  return stream;
105  }
106 
107 
108 private: // I/O
109 
110 
111  /// @brief Assign Stream Bite to Value: Generic Implementation
112  inline
113  void
114  assign( std::stringstream & ss ) const
115  {
116  ss >> t_;
117  }
118 
119 
120 private: // Data
121 
122 
123  int w_; // Width
124  int d_; // Precision (controls implied decimal point location)
125  T & t_; // Reference to value
126 
127 
128 }; // Bite
129 
130 
131 /// @brief Input a Bite from Stream
132 #ifndef __clang__
133 template< typename T >
134 std::istream &
135 operator >>( std::istream & stream, Bite< T > const & bite );
136 #endif
137 
138 
139 /// @brief string is Blank?
140 inline
141 bool
142 is_blank_string( std::string const & s )
143 {
144  if ( s.empty() ) {
145  return true;
146  } else if ( s.find_first_not_of( ' ' ) == std::string::npos ) {
147  return true;
148  } else {
149  return false;
150  }
151 }
152 
153 
154 // Bite Explicit Specializations
155 
156 
157  /// @brief Assign Stream Bite to Value: bool Specialization
158  template<>
159  inline
160  void
161  Bite< bool >::assign( std::stringstream & ss ) const
162  {
163  if ( is_blank_string( ss.str() ) ) {
164  t_ = false;
165  } else {
166  ss >> t_;
167  if ( ss.fail() ) t_ = false;
168  }
169  }
170 
171 
172  /// @brief Assign Stream Bite to Value: byte Specialization
173  template<>
174  void
175  Bite< byte >::assign( std::stringstream & ss ) const;
176 
177 
178  /// @brief Assign Stream Bite to Value: ubyte Specialization
179  template<>
180  void
181  Bite< ubyte >::assign( std::stringstream & ss ) const;
182 
183 
184  /// @brief Assign Stream Bite to Value: char Specialization
185  template<>
186  inline
187  void
188  Bite< char >::assign( std::stringstream & ss ) const
189  {
190  t_ = ( is_blank_string( ss.str() ) ? SPACE : ss.str()[ 0 ] );
191  }
192 
193 
194  /// @brief Assign Stream Bite to Value: signed char Specialization
195  template<>
196  inline
197  void
198  Bite< signed char >::assign( std::stringstream & ss ) const
199  {
200  t_ = ( is_blank_string( ss.str() ) ? SPACE : ss.str()[ 0 ] );
201  }
202 
203 
204  /// @brief Assign Stream Bite to Value: unsigned char Specialization
205  template<>
206  inline
207  void
208  Bite< unsigned char >::assign( std::stringstream & ss ) const
209  {
210  t_ = ( is_blank_string( ss.str() ) ? SPACE : ss.str()[ 0 ] );
211  }
212 
213 
214  /// @brief Assign Stream Bite to Value: short int Specialization
215  template<>
216  inline
217  void
218  Bite< short int >::assign( std::stringstream & ss ) const
219  {
220  if ( is_blank_string( ss.str() ) ) {
221  t_ = 0;
222  } else {
223  ss >> t_;
224  if ( ss.fail() ) t_ = 0;
225  }
226  }
227 
228 
229  /// @brief Assign Stream Bite to Value: unsigned short int Specialization
230  template<>
231  inline
232  void
233  Bite< unsigned short int >::assign( std::stringstream & ss ) const
234  {
235  if ( is_blank_string( ss.str() ) ) {
236  t_ = 0;
237  } else {
238  ss >> t_;
239  if ( ss.fail() ) t_ = 0;
240  }
241  }
242 
243 
244  /// @brief Assign Stream Bite to Value: int Specialization
245  template<>
246  inline
247  void
248  Bite< int >::assign( std::stringstream & ss ) const
249  {
250  if ( is_blank_string( ss.str() ) ) {
251  t_ = 0;
252  } else {
253  ss >> t_;
254  if ( ss.fail() ) t_ = 0;
255  }
256  }
257 
258 
259  /// @brief Assign Stream Bite to Value: unsigned int Specialization
260  template<>
261  inline
262  void
263  Bite< unsigned int >::assign( std::stringstream & ss ) const
264  {
265  if ( is_blank_string( ss.str() ) ) {
266  t_ = 0;
267  } else {
268  ss >> t_;
269  if ( ss.fail() ) t_ = 0;
270  }
271  }
272 
273 
274  /// @brief Assign Stream Bite to Value: long int Specialization
275  template<>
276  inline
277  void
278  Bite< long int >::assign( std::stringstream & ss ) const
279  {
280  if ( is_blank_string( ss.str() ) ) {
281  t_ = 0;
282  } else {
283  ss >> t_;
284  if ( ss.fail() ) t_ = 0;
285  }
286  }
287 
288 
289  /// @brief Assign Stream Bite to Value: unsigned long int Specialization
290  template<>
291  inline
292  void
293  Bite< unsigned long int >::assign( std::stringstream & ss ) const
294  {
295  if ( is_blank_string( ss.str() ) ) {
296  t_ = 0;
297  } else {
298  ss >> t_;
299  if ( ss.fail() ) t_ = 0;
300  }
301  }
302 
303 
304  /// @brief Assign Stream Bite to Value: float Specialization
305  template<>
306  inline
307  void
308  Bite< float >::assign( std::stringstream & ss ) const
309  {
310  if ( is_blank_string( ss.str() ) ) {
311  t_ = 0.0f;
312  } else {
313  using std::string;
314  string s( stripped( ss.str() ) );
315  if ( s.find_first_of( "EeDd" ) == string::npos ) { // No C++ supported exponent
316  string::size_type const i( s.find_last_of( "+-" ) );
317  if ( ( i != string::npos ) && ( i > 0 ) ) { // Fortran exponent form: num+ee or num-ee
318  s.insert( i, 1, 'E' ); // Insert the E
319  ss.str( s );
320  }
321  }
322  ss >> t_;
323  if ( ss.fail() ) {
324  t_ = 0.0f;
325  } else if ( ( d_ != 0 ) && ( ss.str().find( '.' ) == string::npos ) ) { // Implicit decimal point
326  t_ *= std::pow( 10.0, static_cast< double >( -d_ ) );
327  }
328  }
329  }
330 
331 
332  /// @brief Assign Stream Bite to Value: double Specialization
333  template<>
334  inline
335  void
336  Bite< double >::assign( std::stringstream & ss ) const
337  {
338  if ( is_blank_string( ss.str() ) ) {
339  t_ = 0.0;
340  } else {
341  using std::string;
342  string s( stripped( ss.str() ) );
343  if ( s.find_first_of( "EeDd" ) == string::npos ) { // No C++ supported exponent
344  string::size_type const i( s.find_last_of( "+-" ) );
345  if ( ( i != string::npos ) && ( i > 0 ) ) { // Fortran exponent form: num+ee or num-ee
346  s.insert( i, 1, 'E' ); // Insert the E
347  ss.str( s );
348  }
349  }
350  ss >> t_;
351  if ( ss.fail() ) {
352  t_ = 0.0;
353  } else if ( ( d_ != 0 ) && ( ss.str().find( '.' ) == string::npos ) ) { // Implicit decimal point
354  t_ *= std::pow( 10.0, static_cast< double >( -d_ ) );
355  }
356  }
357  }
358 
359 
360  /// @brief Assign Stream Bite to Value: long double Specialization
361  template<>
362  inline
363  void
364  Bite< long double >::assign( std::stringstream & ss ) const
365  {
366  if ( is_blank_string( ss.str() ) ) {
367  t_ = 0.0l;
368  } else {
369  using std::string;
370  string s( stripped( ss.str() ) );
371  if ( s.find_first_of( "EeDd" ) == string::npos ) { // No C++ supported exponent
372  string::size_type const i( s.find_last_of( "+-" ) );
373  if ( ( i != string::npos ) && ( i > 0 ) ) { // Fortran exponent form: num+ee or num-ee
374  s.insert( i, 1, 'E' ); // Insert the E
375  ss.str( s );
376  }
377  }
378  ss >> t_;
379  if ( ss.fail() ) {
380  t_ = 0.0l;
381  } else if ( ( d_ != 0 ) && ( ss.str().find( '.' ) == string::npos ) ) { // Implicit decimal point
382  t_ *= std::pow( 10.0l, static_cast< long double >( -d_ ) );
383  }
384  }
385  }
386 
387 
388  /// @brief Assign Stream Bite to Value: complex< float > Specialization
389  template<>
390  inline
391  void
392  Bite< std::complex< float > >::assign( std::stringstream & ss ) const
393  {
394  if ( is_blank_string( ss.str() ) ) {
395  t_ = 0.0f;
396  } else {
397  //Do Add support for the Fortran exponent forms: num+ee and num-ee
398  ss >> t_;
399  if ( ss.fail() ) {
400  t_ = 0.0f;
401  } else if ( ( d_ != 0 ) && ( ss.str().find( '.' ) == std::string::npos ) ) { // Implicit decimal point
402  t_ *= std::pow( 10.0, static_cast< double >( -d_ ) );
403  }
404  }
405  }
406 
407 
408  /// @brief Assign Stream Bite to Value: complex< double > Specialization
409  template<>
410  inline
411  void
412  Bite< std::complex< double > >::assign( std::stringstream & ss ) const
413  {
414  if ( is_blank_string( ss.str() ) ) {
415  t_ = 0.0;
416  } else {
417  //Do Add support for the Fortran exponent forms: num+ee and num-ee
418  ss >> t_;
419  if ( ss.fail() ) {
420  t_ = 0.0;
421  } else if ( ( d_ != 0 ) && ( ss.str().find( '.' ) == std::string::npos ) ) { // Implicit decimal point
422  t_ *= std::pow( 10.0, static_cast< double >( -d_ ) );
423  }
424  }
425  }
426 
427 
428  /// @brief Assign Stream Bite to Value: complex< long double > Specialization
429  template<>
430  inline
431  void
432  Bite< std::complex< long double > >::assign( std::stringstream & ss ) const
433  {
434  if ( is_blank_string( ss.str() ) ) {
435  t_ = 0.0l;
436  } else {
437  //Do Add support for the Fortran exponent forms: num+ee and num-ee
438  ss >> t_;
439  if ( ss.fail() ) {
440  t_ = 0.0l;
441  } else if ( ( d_ != 0 ) && ( ss.str().find( '.' ) == std::string::npos ) ) { // Implicit decimal point
442  t_ *= std::pow( 10.0l, static_cast< long double >( -d_ ) );
443  }
444  }
445  }
446 
447 
448  /// @brief Assign Stream Bite to Value: string Specialization
449  template<>
450  inline
451  void
452  Bite< std::string >::assign( std::stringstream & ss ) const
453  {
454  t_ = ss.str();
455  }
456 
457 
458  /// @brief Assign Stream Bite to Value: Fstring Specialization
459  template<>
460  void
461  Bite< Fstring >::assign( std::stringstream & ss ) const;
462 
463 
464 // Bite Makers
465 
466 
467 /// @brief Width + Value Bite Maker
468 template< typename T >
469 inline
470 Bite< T >
471 bite( int const w, T & t )
472 {
473  return Bite< T >( w, t );
474 }
475 
476 
477 /// @brief Width + Precision + Value Bite Maker
478 template< typename T >
479 inline
480 Bite< T >
481 bite( int const w, int const d, T & t )
482 {
483  return Bite< T >( w, d, t );
484 }
485 
486 
487 /// @brief bool Bite Maker: Take One Character
488 inline
489 Bite< bool >
490 bite( bool & t )
491 {
492  return Bite< bool >( 1, t );
493 }
494 
495 
496 /// @brief char Bite Maker: Take One Character
497 inline
498 Bite< char >
499 bite( char & t )
500 {
501  return Bite< char >( 1, t );
502 }
503 
504 
505 /// @brief string Bite Maker: Take Rest of Line
506 inline
507 Bite< std::string >
508 bite( std::string & t )
509 {
511 }
512 
513 
514 /// @brief Fstring Bite Maker: Take Length of Fstring
515 Bite< Fstring >
516 bite( Fstring & t );
517 
518 
519 // Skip: Skips Over a Bite of Specified Width from the Input Stream
520 class Skip
521 {
522 
523 
524 public: // Creation
525 
526 
527  /// @brief Constructor
528  inline
529  explicit
530  Skip( int const w = 1 ) :
531  w_( w )
532  {}
533 
534 
535  /// @brief Destructor
536  inline
538  {}
539 
540 
541 public: // I/O
542 
543 
544  /// @brief Input a Skip from Stream
545  friend
546  inline
547  std::istream &
548  operator >>( std::istream & stream, Skip const & skip )
549  {
550  char c;
551  int i( 0 );
552  while ( ( i < skip.w_ ) && ( stream ) && ( stream.peek() != '\n' ) ) {
553  stream.get( c );
554  ++i;
555  }
556  return stream;
557  }
558 
559 
560 private: // Data
561 
562 
563  int w_; // Width
564 
565 
566 }; // Skip
567 
568 
569 /// @brief Input a Skip from Stream
570 #ifndef __clang__
571 std::istream &
572 operator >>( std::istream & stream, Skip const & skip );
573 #endif
574 
575 
576 // Skip Maker and Manipulator
577 
578 
579 /// @brief Skip Maker
580 inline
581 Skip
582 skip( int const w = 1 )
583 {
584  return Skip( w );
585 }
586 
587 
588 /// @brief Skip Rest of Line and Line Terminator (Manipulator)
589 inline
590 std::istream &
591 skip( std::istream & stream )
592 {
593  return stream.ignore( (std::numeric_limits< std::streamsize >::max)(), '\n' );
594 }
595 
596 
597 // Formatted Output
598 
599 
600 // General Formatting
601 
602 
603 /// @brief Single-Spaced Format
604 template< typename T >
605 inline
606 std::string
607 SS( T const & t )
608 {
609  std::ostringstream fmt_stream;
610  fmt_stream << std::left << std::noshowpoint << std::uppercase << ' ' << t;
611  return fmt_stream.str();
612 }
613 
614 
615 /// @brief Single-Spaced Format: bool Specialization
616 template<>
617 std::string
618 SS( bool const & t );
619 
620 
621 /// @brief Single-Spaced Format: float Specialization
622 template<>
623 std::string
624 SS( float const & t );
625 
626 
627 /// @brief Single-Spaced Format: double Specialization
628 template<>
629 std::string
630 SS( double const & t );
631 
632 
633 /// @brief Single-Spaced Format: long double Specialization
634 template<>
635 std::string
636 SS( long double const & t );
637 
638 
639 /// @brief Single-Spaced Format: complex< float > Specialization
640 template<>
641 std::string
642 SS( std::complex< float > const & t );
643 
644 
645 /// @brief Single-Spaced Format: complex< double > Specialization
646 template<>
647 std::string
648 SS( std::complex< double > const & t );
649 
650 
651 /// @brief Single-Spaced Format: complex< long double > Specialization
652 template<>
653 std::string
654 SS( std::complex< long double > const & t );
655 
656 
657 /// @brief Left-Justified Width-Specified Format
658 template< typename T >
659 inline
660 std::string
661 LJ( int const w, T const & t )
662 {
663  std::ostringstream fmt_stream;
664  fmt_stream << std::left << std::setw( w ) << t;
665  return fmt_stream.str();
666 }
667 
668 
669 /// @brief Right-Justified Width-Specified Format
670 template< typename T >
671 inline
672 std::string
673 RJ( int const w, T const & t )
674 {
675  std::ostringstream fmt_stream;
676  fmt_stream << std::right << std::setw( w ) << t;
677  return fmt_stream.str();
678 }
679 
680 
681 // String Formatting
682 
683 
684 /// @brief char Format
685 std::string
686 A( int const w, char const c );
687 
688 
689 /// @brief char Format (Width==1)
690 std::string
691 A( char const c );
692 
693 
694 /// @brief cstring Format
695 std::string
696 A( int const w, c_cstring const s );
697 
698 
699 /// @brief cstring Format (Width of cstring)
700 std::string
701 A( c_cstring const s );
702 
703 
704 /// @brief string Format
705 std::string
706 A( int const w, std::string const & s );
707 
708 
709 /// @brief string Format (Width of string)
710 std::string const &
711 A( std::string const & s );
712 
713 
714 /// @brief Fstring Format
715 std::string
716 A( int const w, Fstring const & s );
717 
718 
719 /// @brief Fstring Format (Width of Fstring)
720 std::string
721 A( Fstring const & s );
722 
723 
724 /// @brief Blank string
725 std::string
726 X( int const w );
727 
728 
729 /// @brief Blank string
730 std::string
731 space( int const w );
732 
733 /// @brief w*c
734 std::string
735 repeat( int const w, char c );
736 
737 
738 // Logical Formatting
739 
740 
741 /// @brief Logical Format
742 std::string
743 L( int const w, bool const & t );
744 
745 
746 /// @brief Logical Format (Width==1)
747 std::string
748 L( bool const & t );
749 
750 
751 // Integer Formatting
752 
753 
754 /// @brief Integer Format
755 template< typename T >
756 inline
757 std::string
758 I( int const w, T const & t )
759 {
760  std::ostringstream fmt_stream;
761  fmt_stream << std::right << std::setw( w ) << t;
762  return fmt_stream.str();
763 }
764 
765 
766 /// @brief Integer Format with Minimum Digits
767 template< typename T >
768 inline
769 std::string
770 I( int const w, int const m, T const & t )
771 {
772  std::ostringstream fmt_stream;
773  fmt_stream << std::right << std::setfill( '0' ) << std::setw( std::min( m, w ) ) << t;
774  std::string const str( fmt_stream.str() );
775  return std::string( std::max( w - static_cast< int >( str.length() ), 0 ), ' ' ) + str;
776 }
777 
778 
779 // Floating Point Formatting
780 
781 
782 /// @brief Exponential Format: float
783 std::string
784 E( int const w, int const d, float const & t );
785 
786 
787 /// @brief Exponential Format: double
788 std::string
789 E( int const w, int const d, double const & t );
790 
791 
792 /// @brief Exponential Format: long double
793 std::string
794 E( int const w, int const d, long double const & t );
795 
796 
797 /// @brief Exponential Format: complex< float >
798 std::string
799 E( int const w, int const d, std::complex< float > const & t );
800 
801 
802 /// @brief Exponential Format: complex< double >
803 std::string
804 E( int const w, int const d, std::complex< double > const & t );
805 
806 
807 /// @brief Exponential Format: complex< long double >
808 std::string
809 E( int const w, int const d, std::complex< long double > const & t );
810 
811 
812 /// @brief Fixed Point Format: float
813 std::string
814 F( int const w, int const d, float const & t );
815 
816 
817 /// @brief Fixed Point Format: double
818 std::string
819 F( int const w, int const d, double const & t );
820 
821 
822 /// @brief Fixed Point Format: long double
823 std::string
824 F( int const w, int const d, long double const & t );
825 
826 
827 /// @brief Fixed Point Format: complex< float >
828 std::string
829 F( int const w, int const d, std::complex< float > const & t );
830 
831 
832 /// @brief Fixed Point Format: complex< double >
833 std::string
834 F( int const w, int const d, std::complex< double > const & t );
835 
836 
837 /// @brief Fixed Point Format: complex< long double >
838 std::string
839 F( int const w, int const d, std::complex< long double > const & t );
840 
841 
842 /// @brief General Format: float
843 std::string
844 G( int const w, int const d, float const & t );
845 
846 
847 /// @brief General Format: double
848 std::string
849 G( int const w, int const d, double const & t );
850 
851 
852 /// @brief General Format: long double
853 std::string
854 G( int const w, int const d, long double const & t );
855 
856 
857 /// @brief General Format: complex< float >
858 std::string
859 G( int const w, int const d, std::complex< float > const & t );
860 
861 
862 /// @brief General Format: complex< double >
863 std::string
864 G( int const w, int const d, std::complex< double > const & t );
865 
866 
867 /// @brief General Format: complex< long double >
868 std::string
869 G( int const w, int const d, std::complex< long double > const & t );
870 
871 
872 // Standard Formatting
873 
874 
875 /// @brief Standard Width Format: Default Implementation
876 template< typename T >
877 inline
878 std::string
879 SW( T const & t )
880 {
881  std::ostringstream fmt_stream;
882  fmt_stream << std::left << std::noshowpoint << std::uppercase << t;
883  return fmt_stream.str();
884 }
885 
886 
887 /// @brief Standard Width Format: bool Specialization
888 template<>
889 std::string
890 SW( bool const & t );
891 
892 
893 /// @brief Standard Width Format: byte Specialization
894 template<>
895 std::string
896 SW( byte const & t );
897 
898 
899 /// @brief Standard Width Format: short Specialization
900 template<>
901 std::string
902 SW( short int const & t );
903 
904 
905 /// @brief Standard Width Format: unsigned short Specialization
906 template<>
907 std::string
908 SW( unsigned short int const & t );
909 
910 
911 /// @brief Standard Width Format: int Specialization
912 template<>
913 std::string
914 SW( int const & t );
915 
916 
917 /// @brief Standard Width Format: unsigned int Specialization
918 template<>
919 std::string
920 SW( unsigned int const & t );
921 
922 
923 /// @brief Standard Width Format: long int Specialization
924 template<>
925 std::string
926 SW( long int const & t );
927 
928 
929 /// @brief Standard Width Format: unsigned long int Specialization
930 template<>
931 std::string
932 SW( unsigned long int const & t );
933 
934 
935 /// @brief Standard Width Format: float Specialization
936 template<>
937 std::string
938 SW( float const & t );
939 
940 
941 /// @brief Standard Width Format: double Specialization
942 template<>
943 std::string
944 SW( double const & t );
945 
946 
947 /// @brief Standard Width Format: long double Specialization
948 template<>
949 std::string
950 SW( long double const & t );
951 
952 
953 /// @brief Standard Width Format: complex< float > Specialization
954 template<>
955 std::string
956 SW( std::complex< float > const & t );
957 
958 
959 /// @brief Standard Width Format: complex< double > Specialization
960 template<>
961 std::string
962 SW( std::complex< double > const & t );
963 
964 
965 /// @brief Standard Width Format: complex< long double > Specialization
966 template<>
967 std::string
968 SW( std::complex< long double > const & t );
969 
970 
971 // Manipulators
972 
973 
974 /// @brief general: Manipulator to Turn Off scientific or fixed
975 std::ios_base &
976 general( std::ios_base & base );
977 
978 
979 // Utility
980 
981 
982 /// @brief Newline utility for formatted output implied DO loop emulation
983 inline
984 std::string
985 nl_if( int const i, int const n )
986 {
987  if ( ( i > 1 ) && ( ( i - 1 ) % n == 0 ) ) {
988  return "\n";
989  } else {
990  return "";
991  }
992 }
993 
994 
995 } // namespace format
996 } // namespace ObjexxFCL
997 
998 
999 #endif // INCLUDED_ObjexxFCL_format_HH
std::string G(int const w, int const d, float const &t)
General Format: float.
Definition: format.cc:486
static T min(T x, T y)
Definition: Svm.cc:16
~Skip()
Destructor.
Definition: format.hh:537
friend std::istream & operator>>(std::istream &stream, Skip const &skip)
Input a Skip from Stream.
Definition: format.hh:548
std::string space(int const w)
Blank string.
Definition: format.cc:271
Skip skip(int const w=1)
Skip Maker.
Definition: format.hh:582
char const * c_cstring
Definition: format.hh:46
std::string X(int const w)
Blank string.
Definition: format.cc:263
cmplx w(cmplx z, double relerr)
Definition: functions.cc:470
char * cstring
Definition: format.hh:45
std::string SS(bool const &t)
Single-Spaced Format: bool Specialization.
Definition: format.cc:92
friend std::istream & operator>>(std::istream &stream, Bite const &bite)
Input a Bite from Stream.
Definition: format.hh:92
std::istream & operator>>(std::istream &stream, Bite< T > const &bite)
Input a Bite from Stream.
Definition: format.hh:92
std::string E(int const w, int const d, float const &t)
Exponential Format: float.
Definition: format.cc:312
~Bite()
Destructor.
Definition: format.hh:81
char const * c_cstring
std::ios_base & general(std::ios_base &base)
general: Manipulator to Turn Off scientific or fixed
Definition: format.cc:696
Bite(int const w, int const d, T &t)
Width + Precision + Value Constructor.
Definition: format.hh:72
std::string L(int const w, bool const &t)
Logical Format.
Definition: format.cc:289
void assign(std::stringstream &ss) const
Assign Stream Bite to Value: Generic Implementation.
Definition: format.hh:114
bool is_blank_string(std::string const &s)
string is Blank?
Definition: format.hh:142
std::string RJ(int const w, T const &t)
Right-Justified Width-Specified Format.
Definition: format.hh:673
DimensionExpressionPow pow(Dimension const &dim1, Dimension const &dim2)
pow( Dimension, Dimension )
std::string F(int const w, int const d, float const &t)
Fixed Point Format: float.
Definition: format.cc:387
std::string stripped(std::string const &s, std::string const &chars)
Specified Characters Stripped from a string's Tails Copy of a string.
Skip(int const w=1)
Constructor.
Definition: format.hh:530
std::string nl_if(int const i, int const n)
Newline utility for formatted output implied DO loop emulation.
Definition: format.hh:985
std::string LJ(int const w, T const &t)
Left-Justified Width-Specified Format.
Definition: format.hh:661
Bite(int const w, T &t)
Width + Value Constructor.
Definition: format.hh:63
Fstring: Fixed-Length Fortran-Compatible String.
Definition: Fstring.hh:53
char const SPACE( ' ')
std::string I(int const w, T const &t)
Integer Format.
Definition: format.hh:758
static T max(T x, T y)
Definition: Svm.cc:19
Bite< Fstring > bite(Fstring &t)
Fstring Bite Maker: Take Length of Fstring.
Definition: format.cc:77
char & uppercase(char &c)
Uppercase a Character.
std::string A(int const w, char const c)
char Format
Definition: format.cc:175
std::string repeat(int const w, char c)
Blank string.
Definition: format.cc:278
byte: One-Byte Integer
Definition: byte.hh:31
std::string SW(FArray1< T > const &a)
Standard Width Format: FArray1.
Definition: FArray1.io.hh:105