TCString.h

Go to the documentation of this file.
00001 //*******************************************************************************
00002 //
00003 // *******   ***   ***               *
00004 //    *     *     *                  *
00005 //    *    *      *                *****
00006 //    *    *       ***  *   *   **   *    **    ***
00007 //    *    *          *  * *   *     *   ****  * * *
00008 //    *     *         *   *      *   * * *     * * *
00009 //    *      ***   ***    *     **   **   **   *   *
00010 //                        *
00011 //*******************************************************************************
00012 // see http://sourceforge.net/projects/tcsystem/ for details.
00013 // Copyright (C) 2003 - 2008 Thomas Goessler. All Rights Reserved. 
00014 //*******************************************************************************
00015 //
00016 // TCSystem is the legal property of its developers.
00017 // Please refer to the COPYRIGHT file distributed with this source distribution.
00018 // 
00019 // This library is free software; you can redistribute it and/or             
00020 // modify it under the terms of the GNU Lesser General Public                
00021 // License as published by the Free Software Foundation; either              
00022 // version 2.1 of the License, or (at your option) any later version.        
00023 //                                                                           
00024 // This library is distributed in the hope that it will be useful,           
00025 // but WITHOUT ANY WARRANTY; without even the implied warranty of            
00026 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         
00027 // Lesser General Public License for more details.                           
00028 //                                                                           
00029 // You should have received a copy of the GNU Lesser General Public          
00030 // License along with this library; if not, write to the Free Software       
00031 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
00032 //*******************************************************************************
00033 //  $Id: TCString.h 849 2008-06-02 20:35:25Z the_____tiger $
00034 //*******************************************************************************
00035 #ifndef _TCSTRING_H_
00036 #define _TCSTRING_H_
00037 
00038 #include "TCTypes.h"
00039 
00040 #include <string>
00041 #include <vector>
00042 #include <cstdarg>
00043 
00044 namespace TC
00045 {
00061    namespace String
00062    {
00063       TCBASE_API std::string ToString(const char* val);
00064       TCBASE_API std::string ToString(char val);
00065       TCBASE_API std::string ToString(bool val);
00066       TCBASE_API std::string ToString(uint64 val);
00067       TCBASE_API std::string ToString(uint32 val);
00068       TCBASE_API std::string ToString(uint16 val);
00069       TCBASE_API std::string ToString(uint8 val);
00070       TCBASE_API std::string ToString(sint64 val);
00071       TCBASE_API std::string ToString(sint32 val);
00072       TCBASE_API std::string ToString(sint16 val);
00073       TCBASE_API std::string ToString(sint8 val);
00074       TCBASE_API std::string ToString(float val);
00075       TCBASE_API std::string ToString(double val);
00076 
00077       TCBASE_API bool IsIntValue(const std::string& text);
00078       TCBASE_API bool IsFltValue(const std::string& text);
00079       TCBASE_API bool IsValue(const std::string& text);
00080 
00081       TCBASE_API bool ToBool(const std::string& text);
00082 
00083       TCBASE_API uint64 ToUint64(const std::string& text);
00084       TCBASE_API uint32 ToUint32(const std::string& text);
00085       TCBASE_API uint16 ToUint16(const std::string& text);
00086       TCBASE_API uint8  ToUint8(const std::string& text);
00087 
00088       TCBASE_API sint64 ToSint64(const std::string& text);
00089       TCBASE_API sint32 ToSint32(const std::string& text);
00090       TCBASE_API sint16 ToSint16(const std::string& text);
00091       TCBASE_API sint8  ToSint8(const std::string& text);
00092 
00093       TCBASE_API double ToFlt64(const std::string& text);
00094       TCBASE_API float ToFlt32(const std::string& text);
00095 
00096       TCBASE_API bool Split(const std::string& text, const std::string& split,
00097                  std::string& text1, std::string& text2);
00098       TCBASE_API bool Split(const std::string& text, uint32 pos,
00099                  std::string& text1, std::string& text2);
00100       TCBASE_API bool Split(const std::string& text, const std::string& split,
00101                  std::vector<std::string>& texts);
00102       TCBASE_API void Join(const std::vector<std::string>& texts, const std::string& split,
00103                 std::string& text);
00104 
00105       TCBASE_API std::string Replace(const std::string& text, char c1, char c2);
00106       TCBASE_API std::string Replace(const std::string& text, const std::string& text1, const std::string& text2);
00107       TCBASE_API std::string ToLower(const std::string& text);
00108       TCBASE_API std::string ToUpper(const std::string& text);
00109 
00110       TCBASE_API std::string DeleteBlanksAndTabs(const std::string& text);
00111       TCBASE_API std::string TrimmSpaces(const std::string& text);
00113       TCBASE_API std::string TrimmLeadingSpaces(const std::string& text);
00115       TCBASE_API std::string TrimmTrailingSpaces(const std::string& text);
00116 
00123       TCBASE_API sint32 StringICompare(const char* s1, const char* s2);
00131       TCBASE_API sint32 StringICompare(const char* s1, const char* s2, uint32 len_to_compare);
00132 
00133       TCBASE_API sint32 Snprintf(char* buf, uint32 size_of_buf, const char *fmt, ...);
00134       TCBASE_API sint32 VSnprintf(char* buf, uint32 size_of_buf, const char *fmt, va_list arguments);
00135       TCBASE_API std::string Print(const char* format, ...);
00136       TCBASE_API std::string VPrint(const char* format, va_list arguments);
00137 
00138    } // namespace String
00139 
00144 } // namspace TC
00145 
00146 #endif  // _TCSTRING_H_

Copyright (c) Thomas Goessler 2003 - 2008