it_bus/string_builder.h

00001 #ifndef _IT_BUS_STRING_BUILDER_H_
00002 #define _IT_BUS_STRING_BUILDER_H_
00003 
00004 // @Copyright 2004 IONA Technologies, Plc. All Rights Reserved.
00005 //
00006 
00007 #include <it_bus/string.h>
00008 #include <it_cal/types.h>
00009 
00010 namespace IT_Bus
00011 {
00012 
00013     class IT_AFC_API StringBuilder : public String
00014     {
00015       public:
00016 
00017         StringBuilder(
00018             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00019         );
00020 
00021         StringBuilder(
00022             const String&        s,
00023             size_t               pos = 0,
00024             size_t               n   = npos,
00025             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00026         );
00027 
00028         StringBuilder(
00029             const char*          str,
00030             size_t               n  = npos,
00031             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00032         );
00033 
00034         StringBuilder(
00035             size_t               n,
00036             char                 c,
00037             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00038         );
00039 
00040         // ostream-like formatted output:
00041         
00042         StringBuilder& operator<<(IT_Bool n);
00043         StringBuilder& operator<<(short n);
00044         StringBuilder& operator<<(unsigned short n);
00045         StringBuilder& operator<<(int n);
00046         StringBuilder& operator<<(unsigned int n);
00047         StringBuilder& operator<<(long n);
00048         StringBuilder& operator<<(unsigned long n);
00049         StringBuilder& operator<<(float f);
00050         StringBuilder& operator<<(double d);
00051         StringBuilder& operator<<(const void* p);
00052         StringBuilder& operator<<(char c);
00053         StringBuilder& operator<<(const char* s);
00054         StringBuilder& operator<<(const String& s);
00055 
00056 #if !IT_LONG_LONG_IS_SAME_AS_LONG
00057         StringBuilder& operator<<(IT_LongLong s);
00058         StringBuilder& operator<<(IT_ULongLong s);
00059 #endif
00060 
00061         StringBuilder& operator<<(
00062             StringBuilder& (*pf)(StringBuilder&)
00063         );
00064 
00065         void hex();
00066         void dec();
00067 
00068       private:
00069         IT_Bool m_hex;
00070     };
00071 }
00072 
00073 // operator overload to allow streaming of CORBA::Exceptions 
00074 // into StringBuilders
00075 namespace CORBA
00076 {
00077     class Exception;
00078 }
00079 
00080 extern IT_AFC_API IT_Bus::StringBuilder&
00081 operator<<(
00082     IT_Bus::StringBuilder& builder, 
00083     const CORBA::Exception& exc
00084 );
00085 
00086 
00087 // String Builder manipulators:
00088 
00089 extern IT_AFC_API IT_Bus::StringBuilder&
00090 hex(
00091     IT_Bus::StringBuilder& sb
00092 );
00093 
00094 extern IT_AFC_API IT_Bus::StringBuilder&
00095 dec(
00096     IT_Bus::StringBuilder& sb
00097 );
00098 
00099 extern IT_AFC_API IT_Bus::StringBuilder&
00100 endl(
00101     IT_Bus::StringBuilder& sb
00102 );
00103 
00104 inline 
00105 IT_Bus::StringBuilder::StringBuilder(
00106     IT_ExceptionHandler& eh
00107 ) : 
00108     String(eh),
00109     m_hex(IT_FALSE)
00110 {}
00111 
00112 inline 
00113 IT_Bus::StringBuilder::StringBuilder(
00114     const IT_Bus::String&   s,
00115     size_t                  pos,
00116     size_t                  n,
00117     IT_ExceptionHandler&    eh
00118 ) : 
00119     String(s, pos, n, eh),
00120     m_hex(IT_FALSE)
00121 {}
00122 
00123 inline 
00124 IT_Bus::StringBuilder::StringBuilder(
00125     const char*          str,
00126     size_t               n,
00127     IT_ExceptionHandler& eh
00128 ) : 
00129     String(str, n, 0, eh),
00130     m_hex(IT_FALSE)
00131 {}
00132 
00133 inline 
00134 IT_Bus::StringBuilder::StringBuilder(
00135     size_t               n,
00136     char                 c,
00137     IT_ExceptionHandler& eh
00138 ) : 
00139     String(n, c, 0, eh),
00140     m_hex(IT_FALSE)
00141 {}
00142 
00143  
00144 #endif  

Generated on Tue Mar 20 15:27:44 2007 for Artix by  doxygen 1.5.1-p1