⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stringutils.hpp

📁 一个gps小工具包
💻 HPP
📖 第 1 页 / 共 5 页
字号:
          * replacement string.  You can specify the number of changes          * to perform.  The default is to change all occurrences of          * the pattern. You can also specify the position in the          * receiver at which to begin.          * @param aString string to perform translation on.          * @param inputString The pattern string as a reference to an          *   object of type string.  The library searches for the          *   pattern string within the receiver's data.          * @param outputString The replacement string as a reference          *   to an object of type string. It replaces the occurrences          *   of the pattern string in the receiver's data.          * @param startPos The position to start the search at within          *   the receiver's data.  The default is 0.          * @param numChanges the number of patterns to search for and          *   change.  The default is to change all occurrences of the          *   pattern.          */      inline std::string& change(std::string& aString,                                 const std::string& inputString,                                 const std::string& outputString,                                 std::string::size_type startPos = 0,                                 unsigned numChanges = std::numeric_limits<unsigned>::max());         /**          * Right-justifies the receiver in a string of the specified          * length. If the receiver's data is shorter than the          * requested length (\a length), it is padded on the left with          * the pad character (\a pad). The default pad          * character is a blank.          * @param s string to be modified.          * @param length new desired length of string.          * @param pad character to pad string with (blank by default).          * @throws StringException if there's a std::exception thrown.          * @return a reference to \a s.  */      inline std::string& rightJustify(std::string& s,                                   const std::string::size_type length,                                   const char pad = ' ')         throw(StringException);         /**          * Right-justifies the receiver in a string of the specified          * length (const version). If the receiver's data is shorter than the          * requested length (\a length), it is padded on the left with          * the pad character (\a pad). The default pad          * character is a blank.          * @param s string to be modified.          * @param length new desired length of string.          * @param pad character to pad string with (blank by default).          * @throws StringException if there's a std::exception thrown.          * @return a reference to \a s.  */      inline std::string rightJustify(const std::string& s,                                  const std::string::size_type length,                                  const char pad = ' ')         throw(StringException)      { std::string t(s); return rightJustify(t, length, pad); }         /**          * Left-justifies the receiver in a string of the specified          * length. If the new length (\a length) is larger than the          * current length, the string is extended by the pad          * character (\a pad). The default pad character is a          * blank.          * @param s string to be modified.          * @param length new desired length of string.          * @param pad character to pad string with (blank by default).          * @throws StringException if there's a std::exception thrown.          * @return a reference to \a s.  */      inline std::string& leftJustify(std::string& s,                                 const std::string::size_type length,                                 const char pad = ' ')         throw(StringException);         /**          * Left-justifies the receiver in a string of the specified          * length (const version). If the new length (\a length) is larger          * than the current length, the string is extended by the pad          * character (\a pad). The default pad character is a          * blank.          * @param s string to be modified.          * @param length new desired length of string.          * @param pad character to pad string with (blank by default).          * @throws StringException if there's a std::exception thrown.          * @return a reference to \a s.  */      inline std::string leftJustify(const std::string& s,                                const std::string::size_type length,                                const char pad = ' ')         throw(StringException)      { std::string t(s); return leftJustify(t, length, pad); }              /**          * Change the length of a string by adding to the beginning and end.          * The string \a s is modified to the specified          * length.  If the string is shorter than          * \a length, then the string is truncated with the          * left-most \a length characters remaining.          * Otherwise, characters are added to the beginning and end of the          * string until the string is the specified length, where the          * number of characters added to the beginning and the end          * does not differ by more than one so the original string          * is centered.          * @param s string to be modified.          * @param length new desired length of string.          * @param pad character to pad string with (blank by default).          * @throws StringException if there's a std::exception thrown.          * @return a reference to \a s.          */      inline std::string& center(std::string& s,             const std::string::size_type length,             const char pad = ' ')         throw(StringException);         /**          * Change the length of a string by adding to the beginning and end          * (const version).          * The string \a s is modified to the specified          * length.  If the string is shorter than          * \a length, then the string is truncated with the          * left-most \a length characters remaining.          * Otherwise, characters are added to the beginning and end of the          * string until the string is the specified length, where the          * number of characters added to the beginning and the end          * does not differ by more than one so the original string          * is centered.          * @param s string to be modified.          * @param length new desired length of string.          * @param pad character to pad string with (blank by default).          * @throws StringException if there's a std::exception thrown.          * @return a reference to \a s.          */      inline std::string center(const std::string& s,                           const std::string::size_type length,                           const char pad = ' ')         throw(StringException)      { std::string t(s); return center(t, length, pad); }         /**          * Convert a string to a double precision floating point number.          * @param s string containing a number.          * @return double representation of string.          */      inline double asDouble(const std::string& s)      { return strtod(s.c_str(), 0); }              /**          * Convert a string to an integer.          * @param s string containing a number.          * @return long integer representation of string.          */      inline long asInt(const std::string& s)      { return strtol(s.c_str(), 0, 10); }              /**          * Convert a string to an unsigned integer.          * @param s string containing a number.          * @return unsigned long integer representation of string.          */      inline unsigned long asUnsigned(const std::string& s)      { return strtoul(s.c_str(), 0, 10); }              /**          * Convert a string to a single precision floating point number.          * @param s string containing a number.          * @return single representation of string.          */      inline float asFloat(const std::string& s)         throw(StringException);         /**          * Convert a string to a big precision floating point number.          * @param s string containing a number.          * @return long double representation of string.          */      inline long double asLongDouble(const std::string& s)         throw(StringException);              /**          * Convert a value in a string to a type specified by the template          * class.  The template class type must have stream operators          * defined.          * @param x object to turn into the templatized type.          * @return the template object of \a x.          */      template <class X>      inline X asData(const std::string& s)         throw(StringException);         /**          * Convert a long double to a string in fixed notation.          * @param x long double.          * @param precision the number of decimal places you want displayed.          * @return string representation of \a x.          */      inline std::string asString(const long double x,                              const std::string::size_type precision = 21);              /**          * Convert a double to a string in fixed notation.          * @param x double.          * @param precision the number of decimal places you want displayed.          * @return string representation of \a x.          */      inline std::string asString(const double x,                              const std::string::size_type precision = 17);              /**          * Convert any old object to a string.          * The class must have stream operators defined.          * @param x object to turn into a string.          * @return string representation of \a x.          */      template <class X>      inline std::string asString(const X x);              /**          * Convert a decimal string to a hexadecimal string.          * Modify the string such that the decimal integer is now          * represented as hexadecimal.  Only the first decimal encountered is          * changed; the rest of the string is unmodified.          * @param s string containing an integer.          * @return reference to modified \a s.          */      inline std::string& d2x(std::string& s)         throw(StringException);              /**          * Convert a decimal string to a hexadecimal string.          * Given a string containing a decimal integer, convert the          * integer from base 10 to base 16 and return the result.  No          * prefix is added.  Only the first decimal encountered is          * changed; the rest of the string is unmodified.          * @param s string containing an integer.          * @return string containing a hexadecimal number.          */      inline std::string d2x(const std::string& s)         throw(StringException)      { std::string t(s);  return d2x(t); }              /**          * Convert a hexadecimal string to a decimal string.          * Modify the string such that the hexadecimal number is now          * represented as decimal.  Only the first hex number encountered          * is changed; the rest of the string is unmodified.          * @param s string containing an integer.          * @return reference to modified \a s.          */      inline std::string& x2d(std::string& s)         throw(StringException);              /**          * Convert a hexadecimal string to a decimal string.          * Given a string containing a hexadecimal number, convert the          * integer from base 16 to base 10 and return the result.          * Only the first hex number encountered          * is changed; the rest of the string is unmodified.          * @param s string containing an integer.          * @return string containing a hexadecimal number.          */      inline std::string x2d(const std::string& s)         throw(StringException)      { std::string t(s);  return x2d(t); }              /**          * Convert a character string to a hexadecimal string.          * Modify the string such that the character string is now          * represented as series of hexadecimal digits.          * @param s string to convert.          * @return reference to modified \a s.          */      inline std::string& c2x(std::string& s)         throw(StringException);         /**          * Convert a character string to a hexadecimal string.          * @param s string containing an integer.          * @return string containing a sequence of hexadecimal numbers.          */      inline std::string c2x(const std::string& s)         throw(StringException)      { std::string t(s);  return c2x(t); }         /**          * Convert a hexadecimal string to an int.          * Only the first hex number encountered is converted.          * @param s string containing a hex integer.          * @return a long holding the value of \a s.          */      inline unsigned int x2int(const std::string& s)         throw(StringException);         /**

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -