GCString.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 (c) 2005 by STEMMER IMAGING
00003 
00004 //  License: This file is published under the license of the EMVA GenICam  Standard Group.
00005 //  A text file describing the legal terms is included in  your installation as 'GenICam_license.pdf'.
00006 //  If for some reason you are missing  this file please contact the EMVA or visit the website
00007 //  (http://www.genicam.org) for a full copy.
00008 //
00009 //  THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
00010 //  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00011 //  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00012 //  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD  GROUP
00013 //  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  SPECIAL,
00014 //  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT  LIMITED TO,
00015 //  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,  DATA, OR PROFITS;
00016 //  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY  THEORY OF LIABILITY,
00017 //  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE)
00018 //  ARISING IN ANY WAY OUT OF THE USE  OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00019 //  POSSIBILITY OF SUCH DAMAGE.
00020 
00021 
00022 ****************************************************************************/
00023 
00027 
00028 
00029 #ifndef GENICAM_GCSTRING_H
00030 #define GENICAM_GCSTRING_H
00031 
00032 #include <new>
00033 #include <string>
00034 #include <iostream>
00035 #include <Base/GCTypes.h>
00036 
00037 #pragma pack(push, 8)
00038 
00039 
00044 #define GCSTRING_NPOS size_t(-1)
00045 
00046 namespace GENICAM_NAMESPACE
00047 {
00052     class GCBASE_API gcstring
00053     {
00054 #       if defined(_MSC_VER) && !defined(PHARLAP_WIN32)
00055     public:
00057             class GCBASE_API gcwchar 
00058             {
00059             public:
00061                 explicit gcwchar( size_t n );
00062 
00063                 // copy constructor
00064                 gcwchar( const gcwchar &rhs );
00065 
00066                 // assignment operator
00067                 gcwchar & operator = (const gcwchar &rhs);
00068 
00070                 const wchar_t * c_str() const;
00071 
00073                 size_t length() const;
00074 
00076                 ~gcwchar();
00077             private:
00078                 class impl;
00079                 impl *m_pimpl;
00080             };
00081 
00082 #       endif
00083 
00084         // Ctor / Dtor
00085         // -------------------------------------------------------------------------
00086     public:
00087         gcstring                ();
00088         gcstring                ( const char *pc );
00089         gcstring                ( const char *pc, size_t n );
00090         gcstring                ( size_t count, char ch );
00091         gcstring                ( const gcstring &str );
00092 #       if defined(_MSC_VER) && !defined(PHARLAP_WIN32)
00093             explicit gcstring   ( const wchar_t *pBufferUTF16 );
00094             gcstring            ( const wchar_t *pBufferUTF16, size_t n );
00095 #       endif
00096         virtual  ~gcstring      ( void );
00097 
00098         // Data access
00099         // -------------------------------------------------------------------------
00100     public:
00101         virtual gcstring &  append                ( const gcstring &str );
00102         virtual gcstring &  append                ( size_t count, char ch );
00103         virtual gcstring &  assign                ( const gcstring &str );
00104         virtual gcstring &  assign                ( size_t count, char ch );
00105         virtual gcstring &  assign                ( const char *pc );
00106         virtual gcstring &  assign                ( const char *pc, size_t n );
00107 #       if defined(_MSC_VER) && !defined(PHARLAP_WIN32)
00108             virtual gcstring &  assign            ( const wchar_t *pStringUTF16 );
00109             virtual gcstring &  assign            ( const wchar_t *pStringUTF16, int n );
00110 #       endif
00111         virtual int         compare               ( const gcstring &str )   const;
00112 #       if defined(_MSC_VER) && !defined(PHARLAP_WIN32)
00113             virtual gcwchar w_str                 ( void )                  const;
00114 #       endif
00115         virtual const char *c_str                 ( void )                  const;
00116         virtual bool        empty                 ( void )                  const;
00117         virtual size_t      find                  ( char ch, size_t offset = 0 ) const;
00118         virtual size_t      find                  ( const gcstring &str, size_t offset = 0 ) const;
00119         virtual size_t      find                  ( const gcstring &str, size_t offset, size_t count ) const;
00120         virtual size_t      find                  ( const char* pc, size_t offset = 0) const;
00121         virtual size_t      find                  ( const char* pc, size_t offset, size_t count ) const;
00122         virtual size_t      length                ( void )                  const;
00123         virtual size_t      size                  ( void )                  const;
00124         virtual void        resize                ( size_t n );
00125         virtual size_t      max_size              ( )                       const;
00126         virtual gcstring    substr                ( size_t offset = 0, size_t count = GCSTRING_NPOS ) const;
00127         virtual size_t      find_first_of         ( const gcstring &str, size_t offset = 0 ) const;
00128         virtual size_t      find_first_not_of     ( const gcstring &str, size_t offset = 0 ) const;
00129         static size_t       _npos                 ( void );
00130         virtual void        swap                  ( gcstring &Right );
00131 
00132 
00133         // Operators
00134         // -------------------------------------------------------------------------
00135     public:
00136         bool                operator !=           ( const gcstring &str )   const;
00137         bool                operator !=           ( const char *pc )        const;
00138         gcstring &          operator +=           ( const gcstring &str );
00139         gcstring            operator +=           ( const gcstring &str )   const;
00140         gcstring &          operator +=           ( const char *pc );
00141 
00142         gcstring &          operator +=           ( char ch );
00143         gcstring            operator +=           ( char ch )               const;
00144         gcstring &          operator =            ( const gcstring &str );
00145 #       if defined(_MSC_VER) && !defined(PHARLAP_WIN32)
00146             gcstring &          operator =        ( const wchar_t *pStringUTF16 );
00147 #       endif
00148         bool                operator ==           ( const gcstring &str )   const;
00149         bool                operator ==           ( const char *pc )        const;
00150         bool                operator <            ( const gcstring &str )   const;
00151         bool                operator >            ( const gcstring &str )   const;
00152         operator const char * ( void )                  const;
00153         void                operator delete       ( void *pWhere );
00154         void                operator delete       ( void *pWhere, void *pNewWhere );
00155         void *              operator new          ( size_t uiSize );
00156         void *              operator new          ( size_t uiSize, void *pWhere );
00157         GCBASE_API
00158         friend gcstring     operator +            ( const gcstring &left, const gcstring &right );
00159         GCBASE_API
00160         friend gcstring     operator +            ( const gcstring &left, const char *right );
00161         GCBASE_API
00162         friend gcstring     operator +            ( const char *left, const gcstring &right );
00163 
00164         // Member
00165         // -------------------------------------------------------------------------
00166     private:
00167         // redundant pointer to make the possible to see the contents of the string in the debugger
00168         const char* m_psz;
00169         // actual std::string object
00170         uint8_t m_opaqueData[64];
00171         
00172         // Constants
00173         // -------------------------------------------------------------------------
00174     public:
00175         // Beware : this static member prevents delay loading
00176         // use _npos() instead
00177         static const size_t npos;
00178     };
00179 }
00180 
00181 namespace GENICAM_NAMESPACE
00182 {
00183     // this is necessary due to the circular dependency between string/exception
00184     GCBASE_API void ThrowBadAlloc(const char *source, int line);
00185 
00188     inline std::istream &  getline(std::istream& is, GENICAM_NAMESPACE::gcstring& str)
00189     {
00190         try
00191         {
00192             std::string tmp;
00193             std::getline(is, tmp);
00194             str.assign(tmp.c_str(), tmp.size());
00195         }
00196         catch(std::bad_alloc &)
00197         {
00198             ThrowBadAlloc(__FILE__, __LINE__);
00199         }
00200         return is;
00201     }
00202 
00205     inline std::istream &  getline(std::istream& is, GENICAM_NAMESPACE::gcstring& str, char delim)
00206     {
00207         try
00208         {
00209             std::string tmp;
00210             std::getline(is, tmp, delim);
00211             str.assign(tmp.c_str(), tmp.size());
00212         }
00213         catch(std::bad_alloc &)
00214         {
00215             ThrowBadAlloc(__FILE__, __LINE__);
00216         }
00217         return is;
00218     }
00219 }
00220 
00221 
00222 
00225 inline std::ostream & operator <<(std::ostream &ostr, const GENICAM_NAMESPACE::gcstring &str)
00226 {
00227     try
00228     {
00229         // use formatted output operator of std::string
00230         ostr << str.c_str();
00231     }
00232     catch(std::bad_alloc &)
00233     {
00234         GENICAM_NAMESPACE::ThrowBadAlloc(__FILE__, __LINE__);
00235     }
00236     return ostr;
00237 }
00238 
00241 inline std::istream & operator >>(std::istream &istr, GENICAM_NAMESPACE::gcstring &str)
00242 {
00243     try
00244     {
00245         std::string tmp;
00246         istr >> tmp;
00247         str.assign(tmp.c_str(), tmp.size());
00248     }
00249     catch(std::bad_alloc &)
00250     {
00251         GENICAM_NAMESPACE::ThrowBadAlloc(__FILE__, __LINE__);
00252     }
00253     return istr;
00254 }
00255 
00256 #pragma pack(pop)
00257 
00258 #endif // GENICAM_GCSTRING_H


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:02