stringutils.h
来自「这是VCF框架的代码」· C头文件 代码 · 共 422 行
H
422 行
#ifndef _VCF_STRINGUTILS_H__#define _VCF_STRINGUTILS_H__//StringUtils.h/*Copyright 2000-2004 The VCF Project.Please see License.txt in the top level directorywhere you installed the VCF.*/#if _MSC_VER > 1000# pragma once#endif#define MAX_TRACE_STRING 5000// forward declaration needed for bcc32class type_info;namespace VCF {class DateTime;class VariantData;class Format;/**\class StringUtils StringUtils.h "vcf/FoundationKit/StringUtils.h"The StringUtils class is a collection of staticutility methods for operating on strings.*/class FOUNDATIONKIT_API StringUtils {public: /** outputs the text to the debugger output @param String the text to output */ static void trace( const VCF::String& text ); /** Similar to trace() but allows variable arguments. Uses the same formatting rules as printf(). @param String the text to trace out after formatting. See printf() for formatting rules. \deprecated This is now a deprecated function and should not be used at all. Existing code should be changed to make use of the traceWithArgs( const Format& ) function instead. It will be removed entirely in an upcoming release. */ //static void traceWithArgs( const VCF::String& text ); static void traceWithArgs( const Format& formatter ); /** formats a string. Uses the same formatting rules as sprintf(). @param String the format text to use @return String the formatted string \deprecated This is now a deprecated function and should not be used at all. Existing code should be changed to make use of the traceWithArgs( const Format& ) function instead. It will be removed entirely in an upcoming release. */ //static VCF::String format( VCF::String formatText, ... ); /** formats a string. Uses the same formatting rules as sprintf(). @param Format the formatter to use @return String the formatted string @see Format */ static VCF::String format( const Format& formatter ); /** trim all the occurrences of a specified character * at the beginning of the string until it is met the first character from the left that is different @param String the text to trim @param char the character to trim @return String the trimmed string */ static VCF::String trimLeft( const VCF::String& text, const char& c ); /** trim all the occurrences of a specified character at the end of the string until it is met the first character from the right that is different @param String the text to trim @param char the character to trim @return String the trimmed string */ static VCF::String trimRight( const VCF::String& text, const char& c ); /** trim all the occurrences of a specified character at the beginning and the end of the string i.e. calls trimLeft + trimRight @param String the text to trim @param char the character to trim @return String the trimmed string */ static VCF::String trim( const VCF::String& text, const char& c ); /** trim all the occurrences of any <space>, <tab>, <CR> and <LF> at the beginning of the string until it is met the first character from the left that is not a whitespace one @param String the text to trim */ static void trimWhiteSpacesLeft( VCF::String& text ); /** trim all the occurrences of any <space>, <tab>, <CR> and <LF> at the end of the string until it is met the first character from the right that is not a whitespace one @param String the text to trim */ static void trimWhiteSpacesRight( VCF::String& text ); /** trim all the occurrences of any <<space>, <tab>, <CR> and <LF> at the beginning and the end of the string i.e. calls trimWhiteSpacesLeft + trimWhiteSpacesRight @param String the text to trim */ static void trimWhiteSpaces( VCF::String& text ); /** gets a copy of the string that is having erased all its characters on the left of the count-th occurrence of the character ch. If the character is not found, the result string is equal to the original one. @param String the source string @param const VCFChar& ch, the char to be searched @param const bool& included, includes the found char in the erasing. By default is false. @param const int& count, number of occurrences of the character to search for. A negative value means a search from the end of the string. Default is +1. in the string. A count = 0 means no erasing on the string. It the count exceeds the number of occurrences in the string then search stops at the last one. @return String, the modified string. */ static String eraseLeftOfChar( const String& s, const VCFChar& ch, const bool& included=false, const int& count=1 ); /** gets a copy of the string that is having erased all its characters on the right of the count-th occurrence of the character ch. If the character is not found, the result string is equal to the original one. @param String the source string @param const VCFChar& ch, the char to be searched @param const bool& included, includes the found char in the erasing. By default is false. @param const int& count, number of occurrences of the character to search for. A negative value means a search from the end of the string. Default is +1. in the string. A count = 0 means no erasing on the string. It the count exceeds the number of occurrences in the string then search stops at the last one. @return String, the modified string. */ static String eraseRightOfChar( const String& s, const VCFChar& ch, const bool& included=false, const int& count=1 ); /** converts the string to lower case @param String the text to convert @return String the converted string */ static VCF::String lowerCase( const VCF::String& text ); /** converts the string to upper case @param String the text to convert @return String the converted string */ static VCF::String upperCase( const VCF::String& text ); /** Performs a case insensitive string compare between str1 and str2. This may not be locale safe, but it will try and use the lower level OS facilities for case insensitive string comparison if they exist. Otherwise it will simply convert both strings to uppercase and compare the results. @return int returns 0 if the strings are equivalent, returns greater than 0 if str1 is greater than str2, and returns less than 0 if str1 is less than str2. */ static int noCaseCompare( const VCF::String& str1, const VCF::String& str2 ); /** converts the value to a string @param uchar the hexadecimal value to convert @return String the string representation of the hexadecimal value */ static VCF::String toStringFromHexNumber( const uchar& value ); /** converts the value to a string @param int the value to convert @return String the string representation of the int value */ static VCF::String toString( const int& value ); /** converts the value to a string @param uint32 the value to convert @return String the string representation of the unsigned int value */ static VCF::String toString( const VCF::uint32& value ); /** converts the value to a string @param long the value to convert @return String the string representation of the long value */ static VCF::String toString( const long& value ); /** converts the value to a string @param ulong32 the value to convert @return String the string representation of the unsigned long value */ static VCF::String toString( const VCF::ulong32& value ); /** converts the value to a string @param VCF::long64 the value to convert @return String the string representation of the VCF::long64 value */ static VCF::String toString( const VCF::long64& value ); /** converts the value to a string @param VCF::ulong64 the value to convert @return String the string representation of the VCF::ulong64 value */ static VCF::String toString( const VCF::ulong64& value ); /** converts the value to a string @param float the value to convert @return String the string representation of the float value */ static VCF::String toString( const float& value ); /** converts the value to a string @param double the value to convert @return String the string representation of the double value */ static VCF::String toString( const double& value ); /** converts the value to a string @param char int the value to convert @return String the string representation of the char value */ static VCF::String toString( const char& value ); /** converts the value to a string @param char bool the value to convert @return String the string representation of the bool value *(either "true" or "false") */ static VCF::String toString( const bool& value ); /** Converts a VariantData instance to a string. @param VariantData the variant to convert @return String the string returned from calling VariantData::toString */ static VCF::String toString( const VariantData& value ); /** converts the value to an hexadecimal number @param String the value to convert @return int the hexadecimal representation of the String value */ static int fromStringAsHexNumber( const VCF::String& value ); /** converts the value to an int @param String the value to convert @return int the integer representation of the String value */ static int fromStringAsInt( const VCF::String& value ); /** converts the value to an unsigned integer @param String the value to convert @return uint32 the unsigned integer representation of the String value */ static VCF::uint32 fromStringAsUInt( const VCF::String& value ); /** converts the value to a long @param String the value to convert @return long the long integer representation of the String value */ static long fromStringAsLong( const VCF::String& value ); /** converts the value to an unsigned long @param String the value to convert @return ulong32 the unsigned long integer representation of the String value */ static VCF::ulong32 fromStringAsULong( const VCF::String& value ); /** converts the value to a 64 bit signed integer @param String the value to convert @return long64 the 64 bit signed integer representation of the String value */ static VCF::long64 fromStringAsLong64( const VCF::String& value ); /** converts the value to a 64 bit unsigned integer @param String the value to convert @return ulong64 the 64 bit unsigned integer representation of the String value */ static VCF::ulong64 fromStringAsULong64( const VCF::String& value ); /** converts the value to an int @param String the value to convert @return int the integer representation of the String value */ static float fromStringAsFloat( const VCF::String& value ); /** converts the value to an int @param String the value to convert @return int the integer representation of the String value */ static double fromStringAsDouble( const VCF::String& value ); /** converts the value to an int @param String the value to convert @return int the integer representation of the String value */ static char fromStringAsChar( const VCF::String& value ); /** converts the value to an int @param String the value to convert @return int the integer representation of the String value */ static short fromStringAsShort( const VCF::String& value ); /** converts the value to an int @param String the value to convert @return int the integer representation of the String value */ static bool fromStringAsBool( const VCF::String& value ); /** generates a new UUID and returns the string representation @return String the new UUID as a string value */ static VCF::String newUUID(); /** gets the class name from a type_info struct. @param type_info the value returned from the expression : \code typeid(AClass) \endcode @return String the name of the class the typeInfo references */ static VCF::String getClassNameFromTypeInfo( const std::type_info& typeInfo ); /** Converts a typeinfo to a string. GCC does such a piss poor job of this that we have to write our own coverter, since the data returned by the GCC implemented type_info::name() is useless. */ static VCF::String toString( const std::type_info& typeInfo ); /** Formats a string from date time object using the various argument/formatting tags in the formatting string. For example, a date that equals "Jan 2, 2005", and a formatting string of "%a %B %#d, %Y" will return string that equals "Sunday January 2, 2005". A listing of the possible format codes follows: <table> <tr> <td>Format code</td> <td>Meaning</td> </tr> <tr> <td>%%</td> <td>outputs just a "%" character</td> </tr> <tr> <td>%a</td> <td>Abbreviated weekday name</td> </tr> <tr> <td>%A</td> <td>Full weekday name</td> </tr> <tr> <td>%b</td> <td>Abbreviated month name</td> </tr> <tr> <td>%B</td> <td>Full month name</td> </tr> <tr> <td>%c</td> <td>Date and time representation appropriate for locale</td> </tr> <tr> <td>%d </td> <td>Day of month as decimal number (01
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?