Scopira 20080306

printflow.h

00001 
00002 /*
00003  *  Copyright (c) 2002-2007    National Research Council
00004  *
00005  *  All rights reserved.
00006  *
00007  *  This material is confidential and proprietary information of
00008  *  National Research Council Canada ("Confidential Information").
00009  *  This Confidential Information may only be used and reproduced
00010  *  in accordance with the terms of the license agreement.
00011  *
00012  */
00013 
00014 #ifndef __INCLUDED_SCOPIRA_TOOL_PRINTFLOW_H__
00015 #define __INCLUDED_SCOPIRA_TOOL_PRINTFLOW_H__
00016 
00017 #include <scopira/tool/flow.h>
00018 #include <scopira/tool/export.h>
00019 #include <scopira/tool/export.h>
00020 
00021 namespace scopira
00022 {
00023   namespace tool
00024   {
00025     class printiflow;
00026     class printoflow;
00027 
00029     SCOPIRA_EXPORT void flow_printf(oflow_i& o, const char* fmt, ...);
00030   }
00031 }
00032 
00042 class scopira::tool::printiflow : public scopira::tool::itflow_i
00043 {
00044   protected:
00046     static bool is_whitespace(byte_t b);
00048     byte_t non_whitespace(void);
00050     count2_ptr< iflow_i > dm_in;
00051     
00052   public:
00060     SCOPIRA_EXPORT printiflow(bool doref, iflow_i* in);
00062     SCOPIRA_EXPORT virtual ~printiflow(void);
00063 
00065     SCOPIRA_EXPORT virtual bool failed(void) const;
00066 
00068     SCOPIRA_EXPORT virtual size_t read(byte_t* _buf, size_t _maxsize);
00069 
00070     // parsing routines
00071 
00072     SCOPIRA_EXPORT virtual bool read_bool(bool&);
00073     SCOPIRA_EXPORT virtual bool read_char(char&);
00074     SCOPIRA_EXPORT virtual bool read_short(short&);
00075     SCOPIRA_EXPORT virtual bool read_int(int&);
00076     SCOPIRA_EXPORT virtual bool read_size_t(size_t&);
00077     SCOPIRA_EXPORT virtual bool read_int64_t(int64_t&);
00078     SCOPIRA_EXPORT virtual bool read_long(long&);
00079     SCOPIRA_EXPORT virtual bool read_float(float&);
00080     SCOPIRA_EXPORT virtual bool read_double(double&);
00081 
00089     SCOPIRA_EXPORT virtual bool read_string(std::string&);
00090 
00092     SCOPIRA_EXPORT void open(iflow_i* in);
00094     SCOPIRA_EXPORT void close(void);
00095 
00096     // extra routines
00097 
00104     SCOPIRA_EXPORT virtual bool read_string(std::string& ret, int _max);
00105 
00111     SCOPIRA_EXPORT bool read_string_word(std::string &ret);
00112 };
00113 
00120 class scopira::tool::printoflow : public scopira::tool::otflow_i
00121 {
00122   protected:
00124     count2_ptr< oflow_i > dm_out;
00125 
00126   public:
00134     SCOPIRA_EXPORT printoflow(bool doref, oflow_i* in);
00136     SCOPIRA_EXPORT virtual ~printoflow(void);
00137       
00139     SCOPIRA_EXPORT virtual bool failed(void) const;
00140 
00142     SCOPIRA_EXPORT virtual size_t write(const byte_t* _buf, size_t _size);
00143 
00144     SCOPIRA_EXPORT virtual void write_bool(bool val);
00145     SCOPIRA_EXPORT virtual void write_char(char val);
00146     SCOPIRA_EXPORT virtual void write_short(short val);
00147     SCOPIRA_EXPORT virtual void write_int(int val);
00148     SCOPIRA_EXPORT virtual void write_size_t(size_t val);
00149     SCOPIRA_EXPORT virtual void write_int64_t(int64_t val);
00150     SCOPIRA_EXPORT virtual void write_long(long val);
00151     SCOPIRA_EXPORT virtual void write_float(float val);
00152     SCOPIRA_EXPORT virtual void write_double(double val);
00153     SCOPIRA_EXPORT virtual void write_string(const std::string& val);
00154 
00156     SCOPIRA_EXPORT void open(oflow_i* in);
00158     SCOPIRA_EXPORT void close(void);
00159 
00161     SCOPIRA_EXPORT void printf(const char* fmt, ...);
00162 };
00163 
00164 #endif
00165