it_bus/string_io.h

00001 #ifndef _IT_BUS_USTRING_IO_H_
00002 #define _IT_BUS_USTRING_IO_H_
00003 
00004 //
00005 //      Copyright (c) 2004 IONA Technologies PLC. All Rights Reserved.
00006 //
00007 
00008 // Provides IO (stream-input functions) for IT_Bus::String
00009 
00010 #include <it_bus/string.h>
00011 #include <it_cal/iostream.h>
00012 
00013 // Helper template classes
00014 // We use templates (instead of inline or static functions) to avoid 
00015 // duplicate copies in multiple translation units of the same 
00016 // library.
00017 // With some compilers it is possible to mix std and classic iostreams
00018 // in the same library: this is why we use different template names.
00019 
00020 #if IT_STD
00021 
00022 template<class T> 
00023 class IT_StdUStringIO
00024 {
00025   public:
00026 
00027     static IT_istream& 
00028     read_string(
00029         IT_istream&   is,
00030         T& s
00031     );
00032     
00033     static IT_istream& 
00034     getline(
00035         IT_istream&          is,
00036         T&                   s,
00037         char                 c
00038     );
00039 };
00040 
00041 #else
00042 
00043 template<class T> 
00044 class IT_CiosUStringIO
00045 {
00046   public:
00047 
00048     static IT_istream& 
00049     read_string(
00050         IT_istream&   is,
00051         T& s
00052     );
00053     
00054     static IT_istream& 
00055     getline(
00056         IT_istream&          is,
00057         T&                   s,
00058         char                 c
00059     );
00060 };
00061 #endif                                           
00062 
00063 inline IT_istream& 
00064 operator>>(
00065     IT_istream&   is,
00066     IT_Bus::String& s
00067 )
00068 {
00069 #if IT_STD
00070     return IT_StdUStringIO<IT_Bus::String>::read_string(is, s);
00071 #else
00072     return IT_CiosUStringIO<IT_Bus::String>::read_string(is, s);
00073 #endif
00074 
00075 }
00076 inline IT_istream& 
00077 getline(
00078     IT_istream&          is,
00079     IT_Bus::String&           s,
00080     char                 c  = '\n'
00081 )
00082 {
00083 #if IT_STD
00084     return IT_StdUStringIO<IT_Bus::String>::getline(is, s, c);
00085 #else
00086     return IT_CiosUStringIO<IT_Bus::String>::getline(is, s, c);
00087 #endif
00088 }
00089 
00090 #if IT_SUPPORTS_COMPILE_TIME_INSTANTIATION
00091 #include <it_bus/string_io.cxx>
00092 #endif
00093 
00094 #endif  

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