Ignore:
Timestamp:
May 4, 2026, 7:26:38 AM (10 days ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
244335b
Parents:
8403b32
Message:

harmonize output quote manipulator with input quote manipulator, adding left/right quote parameters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/iostream.hfa

    r8403b32 rbb1eabc  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat May  2 18:48:56 2026
    13 // Update Count     : 780
     12// Last Modified On : Sun May  3 21:55:06 2026
     13// Update Count     : 829
    1414//
    1515
     
    209209        char base;                                                                                      // numeric base / floating-point style
    210210        inline _Ostream_Manip_Mode;
     211        char qleft, qright;                                                                     // quote delimiters (PLACE HERE SO OPTIONAL IN INITIALIZATION)
    211212}; // _Ostream_Manip
    212213
     
    289290        _Ostream_Manip(char) oct( char c ) { return (_Ostream_Manip(char))@{ .val = c, .wd = 1, .pc = 0, .base = 'o', { .all = 0 } }; }
    290291        _Ostream_Manip(char) hex( char c ) { return (_Ostream_Manip(char))@{ .val = c, .wd = 1, .pc = 0, .base = 'x', { .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) quote( char c, const char qleft = '\'', const char qright = '\0' ) {
     293                return (_Ostream_Manip(char))@{ .val = c, .wd = 1, .pc = 0, .base = 'c', { .flags.quote = true }, .qleft = qleft, .qright = qright }; }
    292294        _Ostream_Manip(char) wd( unsigned int wd, char c ) { return (_Ostream_Manip(char))@{ .val = c, .wd = wd, .pc = 0, .base = 'c', { .all = 0 } }; }
    293295        _Ostream_Manip(char) & wd( unsigned int wd, _Ostream_Manip(char) & fmt ) { fmt.wd = wd; return fmt; }
     
    295297        _Ostream_Manip(char) & upcase( _Ostream_Manip(char) & fmt ) { if ( fmt.base == 'x' || fmt.base == 'b' ) fmt.base -= 32; /* upper case */ return fmt; }
    296298        _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; }
     299        _Ostream_Manip(char) & quote( _Ostream_Manip(char) & fmt, const char qleft = '\'', const char qright = '\0' ) {
     300                fmt.flags.quote = true; fmt.qleft = qleft, fmt.qright = qright; return fmt; }
    298301} // distribution
    299302forall( ostype & | basic_ostream( ostype ) ) {
     
    308311        _Ostream_Manip(const char *) oct( const char s[] ) { return (_Ostream_Manip(const char *))@{ .val = s, .wd = 1, .pc = 0, .base = 'o', { .all = 0 } }; }
    309312        _Ostream_Manip(const char *) hex( const char s[] ) { return (_Ostream_Manip(const char *))@{ .val = s, .wd = 1, .pc = 0, .base = 'x', { .all = 0 } }; }
    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 } }; }
     313        _Ostream_Manip(const char *) quote( const char s[], const char qleft = '"', const char qright = '\0' ) {
     314                return (_Ostream_Manip(const char *))@{ .val = s, .wd = 1, .pc = 0, .base = 's', { .flags.quote = true }, .qleft = qleft, .qright = qright }; }
    311315        _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 } }; }
    312316        _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 } }; }
     
    316320        _Ostream_Manip(const char *) & upcase( _Ostream_Manip(const char *) & fmt ) { if ( fmt.base == 'x' || fmt.base == 'b' ) fmt.base -= 32; /* upper case */ return fmt; }
    317321        _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; } \
     322        _Ostream_Manip(const char *) & quote( _Ostream_Manip(const char *) & fmt, const char qleft = '"', const char qright = '\0' ) {
     323                fmt.flags.quote = true; fmt.qleft = qleft; fmt.qright = qright; return fmt; }
    319324} // distribution
    320325forall( ostype & | basic_ostream( ostype ) ) {
     
    430435        union {
    431436                const char * scanset;
    432                 char delimiters[3];                                                             // [0] => left, [1] => right
     437                char delimiters[3];                                                             // [0] => qleft or terminator, [1] => qright or getline '\0', [2] => char '\0' or char * '\1'
    433438        };
    434439        int wd;                                                                                         // width
Note: See TracChangeset for help on using the changeset viewer.