Changes in / [fc9d167:2fd3de7]
- Files:
-
- 2 added
- 10 edited
-
libcfa/src/collections/string.hfa (modified) (2 diffs)
-
libcfa/src/iostream.cfa (modified) (10 diffs)
-
libcfa/src/iostream.hfa (modified) (5 diffs)
-
tests/collections/.expect/string-api-coverage.txt (modified) (1 diff)
-
tests/collections/.expect/string-ostream.txt (added)
-
tests/collections/string-api-coverage.cfa (modified) (2 diffs)
-
tests/collections/string-istream-manip.cfa (modified) (1 diff)
-
tests/collections/string-ostream.cfa (added)
-
tests/io/.expect/manipulatorsOutput1.arm64.txt (modified) (1 diff)
-
tests/io/.expect/manipulatorsOutput1.x64.txt (modified) (1 diff)
-
tests/io/.expect/manipulatorsOutput1.x86.txt (modified) (1 diff)
-
tests/io/manipulatorsOutput1.cfa (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/collections/string.hfa
rfc9d167 r2fd3de7 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S un Sep 14 10:58:28 202513 // Update Count : 3 1112 // Last Modified On : Sat May 2 19:09:55 2026 13 // Update Count : 322 14 14 // 15 15 … … 87 87 88 88 static inline { 89 _Ostream_Manip(string) bin( string s ) { return (_Ostream_Manip(string))@{ s, 1, 0, 'b', { .all = 0 } }; } 90 _Ostream_Manip(string) oct( string s ) { return (_Ostream_Manip(string))@{ s, 1, 0, 'o', { .all = 0 } }; } 91 _Ostream_Manip(string) hex( string s ) { return (_Ostream_Manip(string))@{ s, 1, 0, 'x', { .all = 0 } }; } 92 _Ostream_Manip(string) wd( unsigned int w, string s ) { return (_Ostream_Manip(string))@{ s, w, 0, 's', { .all = 0 } }; } 93 _Ostream_Manip(string) wd( unsigned int w, unsigned int pc, string s ) { return (_Ostream_Manip(string))@{ s, w, pc, 's', { .flags.pc = true } }; } 94 _Ostream_Manip(string) & wd( unsigned int w, _Ostream_Manip(string) & fmt ) { fmt.wd = w; return fmt; } 95 _Ostream_Manip(string) & wd( unsigned int w, unsigned int pc, _Ostream_Manip(string) & fmt ) { fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; } 89 _Ostream_Manip(string) bin( string s ) { return (_Ostream_Manip(string))@{ .val = s, .wd = 1, .pc = 0, .base = 'b', { .all = 0 } }; } 90 _Ostream_Manip(string) oct( string s ) { return (_Ostream_Manip(string))@{ .val = s, .wd = 1, .pc = 0, .base = 'o', { .all = 0 } }; } 91 _Ostream_Manip(string) hex( string s ) { return (_Ostream_Manip(string))@{ .val = s, .wd = 1, .pc = 0, .base = 'x', { .all = 0 } }; } 92 _Ostream_Manip(string) quote( string s ) { return (_Ostream_Manip(string))@{ .val = s, .wd = 1, .pc = 0, .base = 's', { .flags.quote = true } }; } 93 _Ostream_Manip(string) wd( unsigned int wd, string s ) { return (_Ostream_Manip(string))@{ .val = s, .wd = wd, .pc = 0, .base = 's', { .all = 0 } }; } 94 _Ostream_Manip(string) wd( unsigned int wd, unsigned int pc, string s ) { return (_Ostream_Manip(string))@{ .val = s, .wd = wd, .pc = pc, .base = 's', { .flags.pc = true } }; } 95 _Ostream_Manip(string) & wd( unsigned int wd, _Ostream_Manip(string) & fmt ) { fmt.wd = wd; return fmt; } 96 _Ostream_Manip(string) & wd( unsigned int wd, unsigned int pc, _Ostream_Manip(string) & fmt ) { fmt.wd = wd; fmt.pc = pc; fmt.flags.pc = true; return fmt; } 96 97 _Ostream_Manip(string) & left( _Ostream_Manip(string) & fmt ) { fmt.flags.left = true; return fmt; } 97 98 _Ostream_Manip(string) & nobase( _Ostream_Manip(string) & fmt ) { fmt.flags.nobsdp = true; return fmt; } 99 _Ostream_Manip(string) & upcase( _Ostream_Manip(string) & fmt ) { if ( fmt.base == 'x' || fmt.base == 'b' ) fmt.base -= 32; /* upper case */ return fmt; } 100 _Ostream_Manip(string) & quote( _Ostream_Manip(string) & fmt ) { fmt.flags.quote = true; return fmt; } \ 98 101 } // distribution 99 102 -
libcfa/src/iostream.cfa
rfc9d167 r2fd3de7 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun May 18 08:23:40 202513 // Update Count : 2 17512 // Last Modified On : Sun May 3 08:08:29 2026 13 // Update Count : 2241 14 14 // 15 15 … … 52 52 fmt( os, "%c", c ); 53 53 if ( c == '\n' ) setNL$( os, true ); 54 return nosep( os ); 54 return nosep( os ); // no separator after char 55 55 } // ?|? 56 56 OSTYPE_VOID_IMPL( os, char ) … … 204 204 ostype & ?|?( ostype & os, float _Complex fc ) with ( basic_ostream_table ) { 205 205 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 206 // os | crealf( fc ) | nonl;207 206 PRINT_WITH_DP( os, "%'g", crealf( fc ) ); 208 207 PRINT_WITH_DP( os, "%'+g", cimagf( fc ) ); … … 271 270 if ( ch == '\n' ) setNL$( os, true ); // check *AFTER* sepPrt$ call above as it resets NL flag 272 271 return os; 273 // return write( os, s, len );274 272 } // ?|? 275 273 OSTYPE_VOID_IMPL( os, const char * ) … … 645 643 #define FLOATING_POINT_FMT_IMPL( T, DFMTNP, DFMTP ) \ 646 644 forall( ostype & | basic_ostream( ostype ) ) { \ 647 static void eng( T & value, int & pc, int & exp10 ) { \645 static void eng( T & value, int & pc, int & exp10 ) { \ 648 646 exp10 = lrint( floor( log10( abs( value ) ) ) ); /* round to desired precision */ \ 649 647 if ( exp10 < 0 ) exp10 -= 2; \ … … 697 695 fmtuc.flags.pc = f.flags.pc; 698 696 fmtuc.flags.nobsdp = f.flags.nobsdp; 699 // os | fmtuc | nonl; 697 return (ostype &)(os | fmtuc); 698 } // if 699 if ( f.flags.quote ) { // print as string 700 char qv[] = "' '"; 701 qv[1] = f.val; 702 f.flags.quote = false; // already quoted 703 _Ostream_Manip(const char *) fmtuc @= { qv, f.wd, f.pc, 's', {f.all} }; 700 704 (ostype &)(os | fmtuc); 701 return os;702 } // if 703 704 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 705 706 #define CFMTNP "% * "705 return nosep( os ); // no separator after char 706 } // if 707 708 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 709 710 #define CFMTNP "% *c" 707 711 char fmtstr[sizeof(CFMTNP)]; // sizeof includes '\0' 708 712 memcpy( &fmtstr, CFMTNP, sizeof(CFMTNP) ); … … 713 717 fmtstr[star] = '%'; 714 718 715 fmtstr[sizeof(CFMTNP)-2] = f.base; // sizeof includes '\0'716 719 // printf( "%d %s\n", f.wd, &fmtstr[star] ); 717 720 fmt( os, &fmtstr[star], f.wd, f.val ); 718 return os;721 return nosep( os ); // no separator after char 719 722 } // ?|? 720 723 OSTYPE_VOID_IMPL( os, _Ostream_Manip(char) ) … … 733 736 for ( i; 0 ~ @ : @; f.val[i] != '\0' ) { 734 737 fmtuc.val = f.val[i]; 735 // os | fmtuc | nonl;736 738 (ostype &)(os | fmtuc); 737 739 } // for 738 740 return os; 739 741 } // if 742 if ( f.flags.quote ) { // print as string 743 int len = strlen( f.val ); 744 char qv[len + 3]; // space for quotes and '\0' 745 qv[0] = '"'; // copy string surrounded with quotes 746 strcpy( &qv[1], f.val ); 747 qv[len + 1] = '"'; 748 qv[len + 2] = '\0'; 749 f.flags.quote = false; // already quoted 750 _Ostream_Manip(const char *) fmtuc @= { qv, f.wd, f.pc, 's', {f.all} }; 751 return (ostype &)(os | fmtuc); 752 } // if 740 753 741 754 if ( f.val[0] != '\0' && // null string => no leading separator 742 755 sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 743 756 744 #define SFMTNP "% * "745 #define SFMTP "% *.* "757 #define SFMTNP "% *s" 758 #define SFMTP "% *.*s" 746 759 char fmtstr[sizeof(SFMTP)]; // sizeof includes '\0' 747 760 if ( ! f.flags.pc ) memcpy( &fmtstr, SFMTNP, sizeof(SFMTNP) ); … … 755 768 if ( ! f.flags.pc ) { // no precision 756 769 // printf( "%d %s\n", f.wd, &fmtstr[star] ); 757 fmtstr[sizeof(SFMTNP)-2] = f.base; // sizeof includes '\0'758 770 fmt( os, &fmtstr[star], f.wd, f.val ); 759 771 } else { // precision 760 fmtstr[sizeof(SFMTP)-2] = f.base; // sizeof includes '\0'761 772 // printf( "%d %d %s\n", f.wd, f.pc, &fmtstr[star] ); 762 773 fmt( os, &fmtstr[star], f.wd, f.pc, f.val ); … … 796 807 for () { 797 808 int args = fmt( is, "%c", &temp ); // can be called with EOF on 798 if ( eof( is ) ) throwResume ExceptionInst( end_of_file );809 if ( eof( is ) ) throwResume ExceptionInst( end_of_file ); 799 810 assert( args == 1 ); // if not EOF => a single character must be read 800 811 // do not overwrite parameter with newline unless appropriate 801 if ( temp != '\n' || getANL$( is ) ) { c = temp; break; }812 if ( temp != '\n' || getANL$( is ) ) { c = temp; break; } 802 813 } // for 803 814 return is; -
libcfa/src/iostream.hfa
rfc9d167 r2fd3de7 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jan 14 21:23:53202613 // Update Count : 7 7212 // Last Modified On : Sat May 2 18:48:56 2026 13 // Update Count : 780 14 14 // 15 15 … … 193 193 unsigned char sign:1; // plus / minus sign 194 194 unsigned char pad0:1; // zero pad 195 unsigned char quote:1; // print quotes 195 196 }; 196 197 … … 224 225 _Ostream_Manip(T) & upcase( _Ostream_Manip(T) & fmt ) { if ( fmt.base == 'x' || fmt.base == 'b' ) fmt.base -= 32; /* upper case */ return fmt; } \ 225 226 _Ostream_Manip(T) & nobase( _Ostream_Manip(T) & fmt ) { fmt.flags.nobsdp = true; return fmt; } \ 226 _Ostream_Manip(T) & pad0( _Ostream_Manip(T) & fmt ) { fmt.flags.pad0 = true; return fmt; } \227 227 _Ostream_Manip(T) sign( T val ) { return (_Ostream_Manip(T))@{ .val = val, .wd = 1, .pc = 0, .base = CODE, { .flags.sign = true } }; } \ 228 228 _Ostream_Manip(T) & sign( _Ostream_Manip(T) & fmt ) { fmt.flags.sign = true; return fmt; } \ 229 _Ostream_Manip(T) & pad0( _Ostream_Manip(T) & fmt ) { fmt.flags.pad0 = true; return fmt; } \ 229 230 } /* distribution */ \ 230 231 forall( ostype & | basic_ostream( ostype ) ) { \ … … 288 289 _Ostream_Manip(char) oct( char c ) { return (_Ostream_Manip(char))@{ .val = c, .wd = 1, .pc = 0, .base = 'o', { .all = 0 } }; } 289 290 _Ostream_Manip(char) hex( char c ) { return (_Ostream_Manip(char))@{ .val = c, .wd = 1, .pc = 0, .base = 'x', { .all = 0 } }; } 290 _Ostream_Manip(char) wd( unsigned int wd, char c ) { return (_Ostream_Manip(char))@{ c, wd, 0, .base = 'c', { .all = 0 } }; } 291 _Ostream_Manip(char) quote( char c ) { return (_Ostream_Manip(char))@{ .val = c, .wd = 1, .pc = 0, .base = 'c', { .flags.quote = true } }; } 292 _Ostream_Manip(char) wd( unsigned int wd, char c ) { return (_Ostream_Manip(char))@{ .val = c, .wd = wd, .pc = 0, .base = 'c', { .all = 0 } }; } 291 293 _Ostream_Manip(char) & wd( unsigned int wd, _Ostream_Manip(char) & fmt ) { fmt.wd = wd; return fmt; } 292 294 _Ostream_Manip(char) & left( _Ostream_Manip(char) & fmt ) { fmt.flags.left = true; return fmt; } 293 295 _Ostream_Manip(char) & upcase( _Ostream_Manip(char) & fmt ) { if ( fmt.base == 'x' || fmt.base == 'b' ) fmt.base -= 32; /* upper case */ return fmt; } 294 296 _Ostream_Manip(char) & nobase( _Ostream_Manip(char) & fmt ) { fmt.flags.nobsdp = true; return fmt; } 297 _Ostream_Manip(char) & quote( _Ostream_Manip(char) & fmt ) { fmt.flags.quote = true; return fmt; } 295 298 } // distribution 296 299 forall( ostype & | basic_ostream( ostype ) ) { … … 305 308 _Ostream_Manip(const char *) oct( const char s[] ) { return (_Ostream_Manip(const char *))@{ .val = s, .wd = 1, .pc = 0, .base = 'o', { .all = 0 } }; } 306 309 _Ostream_Manip(const char *) hex( const char s[] ) { return (_Ostream_Manip(const char *))@{ .val = s, .wd = 1, .pc = 0, .base = 'x', { .all = 0 } }; } 307 _Ostream_Manip(const char *) wd( unsigned int wd, const char s[] ) { return (_Ostream_Manip(const char *))@{ s, wd, 0, .base = 's', { .all = 0 } }; } 308 _Ostream_Manip(const char *) wd( unsigned int wd, unsigned int pc, const char s[] ) { return (_Ostream_Manip(const char *))@{ s, .wd = wd, .pc = pc, .base = 's', { .flags.pc = true } }; } 310 _Ostream_Manip(const char *) quote( const char s[] ) { return (_Ostream_Manip(const char *))@{ .val = s, .wd = 1, .pc = 0, .base = 's', { .flags.quote = true } }; } 311 _Ostream_Manip(const char *) wd( unsigned int wd, const char s[] ) { return (_Ostream_Manip(const char *))@{ .val = s, .wd = wd, .pc = 0, .base = 's', { .all = 0 } }; } 312 _Ostream_Manip(const char *) wd( unsigned int wd, unsigned int pc, const char s[] ) { return (_Ostream_Manip(const char *))@{ .val = s, .wd = wd, .pc = pc, .base = 's', { .flags.pc = true } }; } 309 313 _Ostream_Manip(const char *) & wd( unsigned int wd, _Ostream_Manip(const char *) & fmt ) { fmt.wd = wd; return fmt; } 310 314 _Ostream_Manip(const char *) & wd( unsigned int wd, unsigned int pc, _Ostream_Manip(const char *) & fmt ) { fmt.wd = wd; fmt.pc = pc; fmt.flags.pc = true; return fmt; } 311 315 _Ostream_Manip(const char *) & left( _Ostream_Manip(const char *) & fmt ) { fmt.flags.left = true; return fmt; } 316 _Ostream_Manip(const char *) & upcase( _Ostream_Manip(const char *) & fmt ) { if ( fmt.base == 'x' || fmt.base == 'b' ) fmt.base -= 32; /* upper case */ return fmt; } 312 317 _Ostream_Manip(const char *) & nobase( _Ostream_Manip(const char *) & fmt ) { fmt.flags.nobsdp = true; return fmt; } 318 _Ostream_Manip(const char *) & quote( _Ostream_Manip(const char *) & fmt ) { fmt.flags.quote = true; return fmt; } \ 313 319 } // distribution 314 320 forall( ostype & | basic_ostream( ostype ) ) { -
tests/collections/.expect/string-api-coverage.txt
rfc9d167 r2fd3de7 86 86 3 0 0 11 26 0 87 87 abc abcdefghijk abcdefghijklmnopqrstuvwxyz 88 8 3389 1FeC34aB .,; XXX88 8 6 3 89 1FeC34aB .,;'!" XXX 90 90 0 0 3 91 91 1 XXX -
tests/collections/string-api-coverage.cfa
rfc9d167 r2fd3de7 158 158 159 159 160 161 162 160 sout | len(s); // 5 163 161 … … 410 408 sout 411 409 | (return size_t)include( "1FeC34aB", isxdigit ) 412 | (return size_t)include( ".,; ’!\"", ispunct )410 | (return size_t)include( ".,;'!\"", ispunct ) 413 411 | (return size_t)include( "XXXx", isupper ); 414 412 415 413 sout 416 414 | (return string)include( "1FeC34aB", isxdigit ) 417 | (return string)include( ".,; ’!\"", ispunct )415 | (return string)include( ".,;'!\"", ispunct ) 418 416 | (return string)include( "XXXx", isupper ); 419 417 420 418 sout 421 419 | (return size_t)exclude( "1FeC34aB", isdigit ) 422 | (return size_t)exclude( ".,; ’!\"", ispunct )420 | (return size_t)exclude( ".,;'!\"", ispunct ) 423 421 | (return size_t)exclude( "XXXx", islower ); 424 422 425 423 sout 426 424 | (return string)exclude( "1FeC34aB", isalpha ) 427 | (return string)exclude( ".,; ’!\"", ispunct )425 | (return string)exclude( ".,;'!\"", ispunct ) 428 426 | (return string)exclude( "XXXx", islower ); 429 427 } -
tests/collections/string-istream-manip.cfa
rfc9d167 r2fd3de7 1 2 1 #include <fstream.hfa> 3 2 #include <string.hfa> -
tests/io/.expect/manipulatorsOutput1.arm64.txt
rfc9d167 r2fd3de7 38 38 39 39 char 40 a a a a 141 0141 61 0x61 0x61 0X61 a a 41 a a a a 141 0141 61 0x61 0x61 0X61 a a 40 a'a' ' ' a 'a' aa 41 a'a' ' ' a 'a' aa 42 141 0141 141 0141 61 0x61 61 0x61 43 141 0141 141 0141 61 0X61 61 0x61 1100001 0B1100001 1100001 0b1100001 42 44 43 string 44 abcd abcd abcd abcd 45 abcd abcd abcd abcd 46 47 binary string 48 0b110000 0b1100001 0b1100010 0b1100011 0b1100100 0141 0142 0143 0144 0x61 0x62 0x63 0x64 49 110000 1100001 1100010 1100011 1100100 141 142 143 144 61 62 63 64 50 110000 1100001 1100010 1100011 1100100 141 142 143 144 61 62 63 64 45 char * 46 abcd "abcd" abcd "abcd" abcd abcd "abcd" 47 abcd "abcd" abcd "abcd" abcd abcd "abcd" 48 141 142 143 144 0141 0142 0143 0144 141 142 143 144 0141 0142 0143 0144 49 61 62 63 64 0X61 0X62 0X63 0X64 61 62 63 64 0x61 0x62 0x63 0x64 50 1100001 1100010 1100011 1100100 0B1100001 0B1100010 0B1100011 0B1100100 1100001 1100010 1100011 1100100 0b1100001 0b1100010 0b1100011 0b1100100 -
tests/io/.expect/manipulatorsOutput1.x64.txt
rfc9d167 r2fd3de7 38 38 39 39 char 40 a a a a 141 0141 61 0x61 0x61 0X61 a a 41 a a a a 141 0141 61 0x61 0x61 0X61 a a 40 a'a' ' ' a 'a' aa 41 a'a' ' ' a 'a' aa 42 141 0141 141 0141 61 0x61 61 0x61 43 141 0141 141 0141 61 0X61 61 0x61 1100001 0B1100001 1100001 0b1100001 42 44 43 string 44 abcd abcd abcd abcd 45 abcd abcd abcd abcd 46 47 binary string 48 0b110000 0b1100001 0b1100010 0b1100011 0b1100100 0141 0142 0143 0144 0x61 0x62 0x63 0x64 49 110000 1100001 1100010 1100011 1100100 141 142 143 144 61 62 63 64 50 110000 1100001 1100010 1100011 1100100 141 142 143 144 61 62 63 64 45 char * 46 abcd "abcd" abcd "abcd" abcd abcd "abcd" 47 abcd "abcd" abcd "abcd" abcd abcd "abcd" 48 141 142 143 144 0141 0142 0143 0144 141 142 143 144 0141 0142 0143 0144 49 61 62 63 64 0X61 0X62 0X63 0X64 61 62 63 64 0x61 0x62 0x63 0x64 50 1100001 1100010 1100011 1100100 0B1100001 0B1100010 0B1100011 0B1100100 1100001 1100010 1100011 1100100 0b1100001 0b1100010 0b1100011 0b1100100 -
tests/io/.expect/manipulatorsOutput1.x86.txt
rfc9d167 r2fd3de7 38 38 39 39 char 40 a a a a 141 0141 61 0x61 0x61 0X61 a a 41 a a a a 141 0141 61 0x61 0x61 0X61 a a 40 a'a' ' ' a 'a' aa 41 a'a' ' ' a 'a' aa 42 141 0141 141 0141 61 0x61 61 0x61 43 141 0141 141 0141 61 0X61 61 0x61 1100001 0B1100001 1100001 0b1100001 42 44 43 string 44 abcd abcd abcd abcd 45 abcd abcd abcd abcd 45 char * 46 abcd "abcd" abcd "abcd" abcd abcd "abcd" 47 abcd "abcd" abcd "abcd" abcd abcd "abcd" 48 141 142 143 144 0141 0142 0143 0144 141 142 143 144 0141 0142 0143 0144 49 61 62 63 64 0X61 0X62 0X63 0X64 61 62 63 64 0x61 0x62 0x63 0x64 50 1100001 1100010 1100011 1100100 0B1100001 0B1100010 0B1100011 0B1100100 1100001 1100010 1100011 1100100 0b1100001 0b1100010 0b1100011 0b1100100 46 51 47 binary string48 0b110000 0b1100001 0b1100010 0b1100011 0b1100100 0141 0142 0143 0144 0x61 0x62 0x63 0x6449 110000 1100001 1100010 1100011 1100100 141 142 143 144 61 62 63 6450 110000 1100001 1100010 1100011 1100100 141 142 143 144 61 62 63 64 -
tests/io/manipulatorsOutput1.cfa
rfc9d167 r2fd3de7 7 7 // Created On : Sat Jun 8 18:04:11 2019 8 8 // Last Modified By : Peter A. Buhr 9 // Last Modified On : Sat Apr 10 08:42:15 202110 // Update Count : 189 // Last Modified On : Sat May 2 18:50:48 2026 10 // Update Count : 65 11 11 // 12 12 … … 100 100 101 101 sout | nl | "char"; 102 char c = 'a'; 103 printf( "%c %2c %5c %-5c %hho %#hho %hhx %#hhx %#8hhx %#8hhX %-8c %8c\n", c, c, c, c, c, c, c, c, c, c, c, c ); 104 sout | c | ' ' | wd(2,c) | wd(5,c) | left(wd(5,c)) | nobase(oct(c)) | oct(c) | nonl; 105 sout | nobase(hex(c)) | hex(c) | wd(8,hex(c)) | upcase(wd(8,hex(c))) | left(wd(8,c)) | wd(8,c); 102 char c = 'a', * qc = "'a'"; 103 printf( "%c%s%c'%c'%8c%8s%5c%-5c\n", c, qc, ' ', ' ', c, qc, c, c ); 104 sout | c | quote(c) | ' ' | quote(' ') | wd(8,c) | quote( wd(8,c) ) | wd(5,c) | left(wd(5,c)); 105 printf( "%hho %#hho %8hho %#-8hho %hhx %#hhx %8hhx %#-8hhx\n", c, c, c, c, c, c, c, c ); 106 sout | nobase(oct(c)) | upcase(oct(c)) | nobase(wd(8,oct(c))) | left(wd(-8,oct(c))) | nonl; 107 sout | nobase(hex(c)) | upcase(hex(c)) | nobase(wd(8,hex(c))) | left(wd(-8,hex(c))) | nonl; 108 sout | nobase(bin(c)) | upcase(bin(c)) | nobase(wd(12,bin(c))) | left(wd(-12,bin(c))); 106 109 107 sout | nl | "string"; 108 const char * s = "abcd"; 109 printf( "%s %8s %6.8s %-8s\n", s, s, s, s ); 110 sout | s | wd(8,s) | wd(6,8,s) | left(wd(8,s)); 111 112 sout | nl | "binary string"; 113 sout | bin("0") | bin(s) | oct(s) | hex(s); 114 sout | nobase(bin("0")) | nobase(bin(s)) | nobase(oct(s)) | nobase(hex(s)); 115 sout | nobase(wd(8,bin("0"))) | nobase(wd(8,bin(s))) | nobase(wd(4,oct(s))) | nobase(wd(3,hex(s))); 110 sout | nl | "char *"; 111 const char * s = "abcd", * qs = "\"abcd\""; 112 printf( "%s %s %8s %8s %6.8s %-8s %-8s\n", s, qs, s, qs, s, s, qs ); 113 sout | s | quote( s ) | wd(8,s) | quote(wd(8,s)) | wd(6,8,s) | left(wd(8,s)) | quote(left(wd(8,s))); 114 sout | nobase(oct(s)) | upcase(oct(s)) | nobase(wd(8,oct(s))) | left(wd(-8,oct(s))); 115 sout | nobase(hex(s)) | upcase(hex(s)) | nobase(wd(8,hex(s))) | left(wd(-8,hex(s))); 116 sout | nobase(bin(s)) | upcase(bin(s)) | nobase(wd(12,bin(s))) | left(wd(-12,bin(s))); 116 117 } 117 118
Note:
See TracChangeset
for help on using the changeset viewer.