Ignore:
Timestamp:
May 3, 2026, 8:25:27 AM (3 days ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
c136863
Parents:
efa8439a
Message:

add quote output manipulator for printing char, char *, string surrounded by quote characters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/iostream.hfa

    refa8439a rb19b362  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jan 14 21:23:53 2026
    13 // Update Count     : 772
     12// Last Modified On : Sat May  2 18:48:56 2026
     13// Update Count     : 780
    1414//
    1515
     
    193193        unsigned char sign:1;                                                           // plus / minus sign
    194194        unsigned char pad0:1;                                                           // zero pad
     195        unsigned char quote:1;                                                          // print quotes
    195196};
    196197
     
    224225        _Ostream_Manip(T) & upcase( _Ostream_Manip(T) & fmt ) { if ( fmt.base == 'x' || fmt.base == 'b' ) fmt.base -= 32; /* upper case */ return fmt; } \
    225226        _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; } \
    227227        _Ostream_Manip(T) sign( T val ) { return (_Ostream_Manip(T))@{ .val = val, .wd = 1, .pc = 0, .base = CODE, { .flags.sign = true } }; } \
    228228        _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; } \
    229230} /* distribution */ \
    230231forall( ostype & | basic_ostream( ostype ) ) { \
     
    288289        _Ostream_Manip(char) oct( char c ) { return (_Ostream_Manip(char))@{ .val = c, .wd = 1, .pc = 0, .base = 'o', { .all = 0 } }; }
    289290        _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 } }; }
    291293        _Ostream_Manip(char) & wd( unsigned int wd, _Ostream_Manip(char) & fmt ) { fmt.wd = wd; return fmt; }
    292294        _Ostream_Manip(char) & left( _Ostream_Manip(char) & fmt ) { fmt.flags.left = true; return fmt; }
    293295        _Ostream_Manip(char) & upcase( _Ostream_Manip(char) & fmt ) { if ( fmt.base == 'x' || fmt.base == 'b' ) fmt.base -= 32; /* upper case */ return fmt; }
    294296        _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; }
    295298} // distribution
    296299forall( ostype & | basic_ostream( ostype ) ) {
     
    305308        _Ostream_Manip(const char *) oct( const char s[] ) { return (_Ostream_Manip(const char *))@{ .val = s, .wd = 1, .pc = 0, .base = 'o', { .all = 0 } }; }
    306309        _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 } }; }
    309313        _Ostream_Manip(const char *) & wd( unsigned int wd, _Ostream_Manip(const char *) & fmt ) { fmt.wd = wd; return fmt; }
    310314        _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; }
    311315        _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; }
    312317        _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; } \
    313319} // distribution
    314320forall( ostype & | basic_ostream( ostype ) ) {
Note: See TracChangeset for help on using the changeset viewer.