it_bus/stream_transformer.h

00001 #ifndef _STRING_TEMPLATE_PROCESSOR_H_
00002 #define _STRING_TEMPLATE_PROCESSOR_H_
00003 
00004 //
00005 //      Copyright (c) 2002 IONA Technologies PLC. All Rights Reserved.
00006 // 
00007 //
00008 
00009 #ifndef IT_MINIMISE_INCLUDES
00010 #include <it_bus/binary_buffer.h>
00011 #endif
00012 
00013 #include <it_dsa/vector.h>
00014 #include <it_bus/string_map.h>
00015 #include <it_bus/types.h>
00016 #include <it_bus/exception.h>
00017 
00018 namespace IT_Bus
00019 {
00020     class BinaryBuffer;
00021     class IT_AFC_API StreamTransformerException : public Exception
00022         {
00023           public:
00024             StreamTransformerException(
00025                 const char * desc1 = 0,
00026                 const char * desc2 = 0,
00027                 const char * desc3 = 0,
00028                 const char * desc4 = 0,
00029                 const char * desc5 = 0,
00030                 const char * desc6 = 0
00031             );
00032 
00033             StreamTransformerException(
00034                 IT_ULong error_code, 
00035                 const char * desc1 = 0,
00036                 const char * desc2 = 0,
00037                 const char * desc3 = 0,
00038                 const char * desc4 = 0,
00039                 const char * desc5 = 0,
00040                 const char * desc6 = 0
00041             );
00042 
00043             virtual ~StreamTransformerException();
00044 
00048             virtual Exception*
00049             clone() const;
00050         
00054             virtual void
00055             rethrow() const;
00056         };
00057 
00058 
00059         class IT_AFC_API StreamTransformer;
00060 
00061         class IT_AFC_API KeywordTransformer
00062         {
00063         public:
00064             KeywordTransformer();
00065 
00066             KeywordTransformer(
00067                  const KeywordTransformer&
00068             );
00069 
00070             virtual
00071             ~KeywordTransformer();
00072 
00073             virtual
00074             void
00075             transform(
00076                 StreamTransformer&,
00077                 BinaryBuffer&
00078             ) IT_THROW_DECL((IT_Bus::StreamTransformerException)) = 0;
00079         };
00080 
00081         class IT_AFC_API StreamTransformer
00082         {
00083           typedef IT_Pair<char, char>                 DelimPairType;
00084           typedef IT_Vector<DelimPairType>            DelimPairVectorType;
00085           typedef StringMap<KeywordTransformer*>      KeywordTransformerMapType;
00086 
00087         public:
00088             StreamTransformer();
00089 
00090             virtual
00091             ~StreamTransformer();
00092 
00093             void
00094             register_keyword(
00095                 const String&,
00096                 KeywordTransformer*
00097             );
00098 
00099             void
00100             register_delimiters(
00101                 char,
00102                 char
00103             );
00104 
00105             void
00106             transform(
00107                 const BinaryBuffer&,
00108                 BinaryBuffer&
00109             ) IT_THROW_DECL((IT_Bus::StreamTransformerException));
00110 
00111             void
00112             transform(
00113                 const String&,
00114                 String&
00115             ) IT_THROW_DECL((IT_Bus::StreamTransformerException));
00116 
00117 
00118         protected:
00119             int
00120             get_next_token(
00121                 String&, 
00122                 const BinaryBuffer&
00123             );
00124 
00125             KeywordTransformerMapType                       m_transformer_map;
00126             DelimPairVectorType                             m_delims;
00127             int                                             m_iter;
00128         };
00129 
00130         class IT_AFC_API FilenameTransformer : public StreamTransformer
00131         {
00132         public:
00133             FilenameTransformer();
00134 
00135             virtual
00136             ~FilenameTransformer();
00137         };
00138 
00139         class IT_AFC_API KeywordTransformer_PID : public KeywordTransformer
00140         {
00141         public:
00142             KeywordTransformer_PID();
00143 
00144             KeywordTransformer_PID(
00145                  const KeywordTransformer_PID&
00146             );
00147 
00148             virtual
00149             ~KeywordTransformer_PID();
00150 
00151             virtual
00152             void
00153             transform(
00154                 StreamTransformer&,
00155                 BinaryBuffer&
00156             ) IT_THROW_DECL((IT_Bus::StreamTransformerException));
00157         };
00158 }
00159 
00160 #endif // #define _STRING_TEMPLATE_PROCESSOR_H_

Generated on Thu Sep 7 11:39:05 2006 for Artix by  doxygen 1.4.7