Scopira 20080306

propflow.h

00001 
00002 /*
00003  *  Copyright (c) 2002    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_PROPFLOW_H__
00015 #define __INCLUDED_SCOPIRA_TOOL_PROPFLOW_H__
00016 
00017 #include <scopira/tool/flow.h>
00018 #include <scopira/tool/export.h>
00019 
00020 namespace scopira
00021 {
00022   namespace tool
00023   {
00024     class commentiflow;
00025 
00026     class propiflow;
00027     class propoflow;
00028     class property;
00029   }
00030 }
00031 
00032 //
00033 // rightnow it can read from a custom and custom-old
00034 // text format.
00035 //  future file formats include: XML, Win32 registry
00036 //
00037 
00043 class scopira::tool::commentiflow : public scopira::tool::iflow_i
00044 {
00045   protected:
00047     count2_ptr< iflow_i > dm_in;
00048     bool dm_atzero;
00049 
00050   public:
00052     commentiflow(bool doref, iflow_i* in);
00053 
00055     virtual bool failed(void) const;
00056 
00058     virtual size_t read(byte_t* _buf, size_t _maxsize);
00060     virtual size_t read_byte(byte_t &out);
00061 
00063     void open(iflow_i* in);
00065     void close(void);
00066 };
00067 
00074 class scopira::tool::propiflow : public scopira::tool::iobjflow_i
00075 {
00076   protected:
00078     static bool is_whitespace(byte_t b);
00080     byte_t non_whitespace(void);
00081 
00083     count2_ptr< iflow_i > dm_in;
00084 
00085   public:
00093     SCOPIRA_EXPORT propiflow(bool doref, iflow_i* in);
00095     SCOPIRA_EXPORT virtual ~propiflow(void);
00096 
00098     SCOPIRA_EXPORT virtual bool failed(void) const;
00099 
00101     SCOPIRA_EXPORT virtual size_t read(byte_t* _buf, size_t _maxsize);
00102 
00103     SCOPIRA_EXPORT virtual bool read_bool(bool&);
00104     SCOPIRA_EXPORT virtual bool read_char(char&);
00105     SCOPIRA_EXPORT virtual bool read_short(short&);
00106     SCOPIRA_EXPORT virtual bool read_int(int&);
00107     SCOPIRA_EXPORT virtual bool read_size_t(size_t&);
00108     SCOPIRA_EXPORT virtual bool read_int64_t(int64_t&);
00109     SCOPIRA_EXPORT virtual bool read_long(long&);
00110     SCOPIRA_EXPORT virtual bool read_float(float&);
00111     SCOPIRA_EXPORT virtual bool read_double(double&);
00112     SCOPIRA_EXPORT virtual bool read_string(std::string&);
00113 
00115     SCOPIRA_EXPORT virtual bool read_object(object* &out);
00116 
00125     SCOPIRA_EXPORT bool read_keyword(std::string& ret, bool& keyword);
00126 
00128     SCOPIRA_EXPORT void open(iflow_i* in);
00130     SCOPIRA_EXPORT void close(void);
00131 
00134     bool read_property(property* rp, int level = 0);
00135 };
00136 
00143 class scopira::tool::propoflow : public scopira::tool::oobjflow_i
00144 {
00145   protected:
00147     count2_ptr< oflow_i > dm_out;
00148 
00149   public:
00157     SCOPIRA_EXPORT propoflow(bool doref, oflow_i* out);
00159     SCOPIRA_EXPORT virtual ~propoflow(void);
00160       
00162     SCOPIRA_EXPORT virtual bool failed(void) const;
00163 
00165     SCOPIRA_EXPORT virtual size_t write(const byte_t* _buf, size_t _size);
00166 
00167     SCOPIRA_EXPORT virtual void write_bool(bool val);
00168     SCOPIRA_EXPORT virtual void write_char(char val);
00169     SCOPIRA_EXPORT virtual void write_short(short val);
00170     SCOPIRA_EXPORT virtual void write_int(int val);
00171     SCOPIRA_EXPORT virtual void write_size_t(size_t val);
00172     SCOPIRA_EXPORT virtual void write_int64_t(int64_t val);
00173     SCOPIRA_EXPORT virtual void write_long(long val);
00174     SCOPIRA_EXPORT virtual void write_float(float val);
00175     SCOPIRA_EXPORT virtual void write_double(double val);
00176     SCOPIRA_EXPORT virtual void write_string(const std::string& val);
00177 
00179     SCOPIRA_EXPORT virtual void write_object(const scopira::tool::object* o);
00180 
00182     SCOPIRA_EXPORT void write_keyword(const std::string& i);
00184     SCOPIRA_EXPORT void write_indent(int n);
00185 
00187     SCOPIRA_EXPORT void open(oflow_i* out);
00189     SCOPIRA_EXPORT void close(void);
00190 
00192     SCOPIRA_EXPORT void write_property(property* rp, int indent = 0);
00193 };
00194 
00195 #endif
00196