mxmString.h

00001 //           ///          //                                  C++ Cross Platform
00002 //          /////        ////
00003 //         /// XXX     XXX ///            ///////////   /////////     ///   ///
00004 //        ///    XXX XXX    ///         ///             ///    ///   ///  ///
00005 //       ///       XXX       ///         /////////     ///      //  //////
00006 //      ///      XXX XXX      ///               ///   ///    ///   ///  ///
00007 //     ////    XXX     XXX    ////    ////////////  //////////    ///   ///
00008 //    ////                     ////
00009 //   ////  M  O  B  O  T  I  X  ////////////////////////////////////////////////
00010 //  //// Security Vision Systems //////////////////////////////////////////////
00011 //
00012 //  $Author: khe_admin $
00013 //  $LastChangedBy: khe_admin $
00014 //  $LastChangedDate: 2007-06-29 15:34:53 +0200 (Fri, 29 Jun 2007) $
00015 //  $HeadURL: http://svn.mobotix.net/svn/mxsdk/src/mxm/trunk/include/mxm/core/mxmString.h $
00016 //
00018      //
00019      //  MOBOTIX MxPEG SDK
00020      //
00021      //  This file belongs to the C++ library released as part of the MxPEG SDK.
00022      //
00023      //  This software is licenced under the BSD licence,
00024      //  http://www.opensource.org/licenses/bsd-license.php
00025      //
00026      //  Copyright (c) 2005 - 2007, MOBOTIX AG
00027      //  All rights reserved.
00028      //
00029      //  Redistribution and use in source and binary forms, with or without
00030      //  modification, are permitted provided that the following conditions are
00031      //  met:
00032      //
00033      //  - Redistributions of source code must retain the above copyright
00034      //    notice, this list of conditions and the following disclaimer.
00035      //
00036      //  - Redistributions in binary form must reproduce the above copyright
00037      //    notice, this list of conditions and the following disclaimer in the
00038      //    documentation and/or other materials provided with the distribution.
00039      //
00040      //  - Neither the name of MOBOTIX AG nor the names of its contributors may
00041      //    be used to endorse or promote products derived from this software
00042      //    without specific prior written permission.
00043      //
00044      //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00045      //  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00046      //  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00047      //  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00048      //  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00049      //  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00050      //  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00051      //  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00052      //  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00053      //  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00054      //  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00055      //
00057 
00058 
00059 
00060 #ifndef __MXM_STRING_H__
00061 #define __MXM_STRING_H__
00062 
00063 
00064 
00065 #include <mxm/core/mxmObject.h>
00066 #include <mxm/core/mxm_smart.h>
00067 
00068 #include <cstdio>
00069 
00070 
00071 
00072 class mxmStringList;
00073 
00074 
00075 
00078 
00125 class MXM_CORE_API mxmString : public mxmObject {
00126   
00127  private:
00128   static const char *Base64EncodeTable;
00129    
00130  private:
00131   char *TextBuffer;
00132   int BufferedChar;
00133   bool CharBuffered;
00134   void *StableABIDataExtension;
00135   
00136  public:
00138   static mxmString nullString(void);
00139   
00140  public:
00142   mxmString();
00144   mxmString(const char *txt);
00146   mxmString(const mxmString &txt);
00148   mxmString(int numba);
00149   ~mxmString();
00150   
00151  public:
00152   mxmString &operator=(const char *txt);
00153   mxmString &operator=(const mxmString &txt);
00154   mxmString &operator+=(const mxmString &txt);
00155   mxmString &operator+=(const char *txt);
00156   bool operator==(const mxmString &txt) const;
00157   bool operator!=(const mxmString &txt) const;
00159   bool operator<=(const mxmString &txt) const;
00162   mxmStringList operator,(const mxmString &other_string);
00163   
00164  public:
00166   void setText(const char *txt);
00168   const char *text(void) const;
00170   void setNull(void);
00172   bool isNull(void) const;
00174   int length(void) const;
00177   void setLength(int len, char fill_character = ' ');
00181   int characterPosition(char c) const;
00183   void append(const mxmString &txt);
00185   bool split(mxmString &left, mxmString &right,
00186              const mxmString &separators,
00187              bool search_from_behind = false) const;
00190   bool splitUsingSeparatorStrings(mxmString &left, mxmString &right,
00191                                   const mxmStringList &separator_strings);
00193   void trim(const mxmString &delimiters);
00195   void purgeCharacters(const mxmString &characters_to_purge,
00196                        bool invert_logic = false,
00197                        const char *replacement_character = 0);
00200   void replace(mxmString const &search, mxmString const & replacement);
00202   mxmString HTMLEscaped(bool const strict = false) const;
00204   void escapeHTML(bool const strict = false);
00208   mxmString urlPercentSymbolEscaped(const mxmString &characters_to_escape)
00209       const;
00212   void escapeURLPercentSymbol(mxmString const & characters_to_escape);
00214   bool unescapeURLPercentSymbols();
00217   mxmString urlPercentSymbolsUnescaped(void) const;
00219   bool unescapeURL();
00221   mxmString urlUnescaped(void) const;
00223   mxmString base64(void) const;
00225   mxmString left(int character_num) const;
00228   mxmString mid(int character_start, int character_len) const;
00231   mxmString left(const mxmString &valid_characters) const;
00235   int findSubString(mxmString const & search, int start_from = 0) const;
00238   bool subString(const mxmString &another_string) const;
00241   mxm::smart<mxmStringList> tokenize(const mxmString &separators,
00242                                      const mxmString &characters_to_trim = "")
00243                              const;
00245   mxm::smart<mxmStringList> tokenizeUsingSeparatorStrings(
00246                               const mxmStringList &separator_strings,
00247                               const mxmString &characters_to_trim = "") const;
00248   
00251   bool toInt(int &target_int);
00252   
00253  public:
00255   static bool areEqualIgnoringCase(const mxmString &txt1,
00256                                    const mxmString &txt2);
00257 };
00258 
00259 
00260 MXM_CORE_API mxmString operator+(const mxmString &txt1, const mxmString &txt2);
00261 MXM_CORE_API mxmString operator+(const char *txt1, const mxmString &txt2);
00262 
00263 
00264 
00265 #endif   // __MXM_STRING_H__
00266 

Generated on Fri Jun 29 17:21:04 2007 for MxPEG SDK by  doxygen 1.4.6