Changeset 6de9f4a for src/libcfa


Ignore:
Timestamp:
Sep 11, 2017, 5:15:47 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
cd218e8
Parents:
7b1d5ec
Message:

add I/O for signed/unsigned char/short, and output for char16_t, char32_t, wchar_t

Location:
src/libcfa
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/iostream

    r7b1d5ec r6de9f4a  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 24 08:14:29 2017
    13 // Update Count     : 133
     12// Last Modified On : Mon Sep 11 09:17:07 2017
     13// Update Count     : 137
    1414//
    1515
    1616#pragma once
    1717
     18#include <uchar.h>
     19#include <wchar.h>
    1820#include "iterator"
    1921
     
    7880
    7981forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const char * );
     82forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const char16_t * );
     83forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const char32_t * );
     84forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const wchar_t * );
    8085forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, const void * );
    8186
     
    118123
    119124forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, char & );
     125forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, signed char & );
     126forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, unsigned char & );
    120127
    121128forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, short int & );
  • src/libcfa/iostream.c

    r7b1d5ec r6de9f4a  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 24 08:41:53 2017
    13 // Update Count     : 405
     12// Last Modified On : Mon Sep 11 09:21:24 2017
     13// Update Count     : 420
    1414//
    1515
     
    145145
    146146forall( dtype ostype | ostream( ostype ) )
    147 ostype * ?|?( ostype * os, const char * cp ) {
     147ostype * ?|?( ostype * os, const char * str ) {
    148148        enum { Open = 1, Close, OpenClose };
    149149        static const unsigned char mask[256] @= {
     
    161161        }; // mask
    162162
    163   if ( cp[0] == '\0' ) { sepOff( os ); return os; }             // null string => no separator
     163  if ( str[0] == '\0' ) { sepOff( os ); return os; }            // null string => no separator
    164164
    165165        // first character IS NOT spacing or closing punctuation => add left separator
    166         unsigned char ch = cp[0];                                                       // must make unsigned
     166        unsigned char ch = str[0];                                                      // must make unsigned
    167167        if ( sepPrt( os ) && mask[ ch ] != Close && mask[ ch ] != OpenClose ) {
    168168                fmt( os, "%s", sepGetCur( os ) );
     
    173173
    174174        // last character IS spacing or opening punctuation => turn off separator for next item
    175         size_t len = strlen( cp );
    176         ch = cp[len - 1];                                                                       // must make unsigned
     175        size_t len = strlen( str );
     176        ch = str[len - 1];                                                                      // must make unsigned
    177177        if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
    178178                sepOn( os );
     
    181181        } // if
    182182        if ( ch == '\n' ) setNL( os, true );                            // check *AFTER* sepPrt call above as it resets NL flag
    183         return write( os, cp, len );
     183        return write( os, str, len );
     184} // ?|?
     185
     186forall( dtype ostype | ostream( ostype ) )
     187ostype * ?|?( ostype * os, const char16_t * str ) {
     188        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     189        fmt( os, "%ls", str );
     190        return os;
     191} // ?|?
     192
     193forall( dtype ostype | ostream( ostype ) )
     194ostype * ?|?( ostype * os, const char32_t * str ) {
     195        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     196        fmt( os, "%ls", str );
     197        return os;
     198} // ?|?
     199
     200forall( dtype ostype | ostream( ostype ) )
     201ostype * ?|?( ostype * os, const wchar_t * str ) {
     202        if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) );
     203        fmt( os, "%ls", str );
     204        return os;
    184205} // ?|?
    185206
     
    277298
    278299forall( dtype istype | istream( istype ) )
     300istype * ?|?( istype * is, signed char & sc ) {
     301        fmt( is, "%hhd", &sc );
     302        return is;
     303} // ?|?
     304
     305forall( dtype istype | istream( istype ) )
     306istype * ?|?( istype * is, unsigned char & usc ) {
     307        fmt( is, "%hhu", &usc );
     308        return is;
     309} // ?|?
     310
     311forall( dtype istype | istream( istype ) )
    279312istype * ?|?( istype * is, short int & si ) {
    280313        fmt( is, "%hd", &si );
Note: See TracChangeset for help on using the changeset viewer.