Lines Matching full:string
32 #include <string>
47 /// Finds the next placeholder in a string.
49 /// \param format The original format string provided by the user; needed for
51 /// \param expansion The string containing the placeholder to look for. Any
52 /// '%%' in the string will be skipped, and they must be stripped later by
57 /// \return The position in the string in which the placeholder is located and
59 /// the length of the string and an empty string.
61 /// \throw bad_format_error If the input string contains a trailing formatting
64 static std::pair< std::string::size_type, std::string >
65 find_next_placeholder(const std::string& format, in find_next_placeholder()
66 const std::string& expansion, in find_next_placeholder()
67 std::string::size_type begin) in find_next_placeholder()
70 while (begin != std::string::npos && expansion[begin + 1] == '%') in find_next_placeholder()
72 if (begin == std::string::npos) in find_next_placeholder()
77 std::string::size_type end = begin + 1; in find_next_placeholder()
80 const std::string placeholder = expansion.substr(begin, end - begin + 1); in find_next_placeholder()
82 placeholder.find('%', 1) != std::string::npos) in find_next_placeholder()
89 /// Converts a string to an integer.
91 /// \param format The format string; for error reporting purposes only.
92 /// \param str The string to conver.
96 /// \return An integer representing the input string.
98 to_int(const std::string& format, const std::string& str, const char* what) in to_int()
103 throw format::bad_format_error(format, "Invalid " + std::string(what) + in to_int()
116 /// \throw bad_format_error If the format string is bad. We do minimal
117 /// validation on this string though.
119 new_ostringstream(const std::string& format) in new_ostringstream()
132 std::string partial = format.substr(1, format.length() - 2); in new_ostringstream()
138 const std::string::size_type dot = partial.find('.'); in new_ostringstream()
141 if (dot != std::string::npos) { in new_ostringstream()
153 /// Replaces '%%' by '%' in a given string range.
155 /// \param in The input string to be rewritten.
159 /// \return The modified string and the amount of characters removed.
160 static std::pair< std::string, int >
161 strip_double_percent(const std::string& in, const std::string::size_type begin, in strip_double_percent()
162 std::string::size_type end) in strip_double_percent()
164 std::string part = in.substr(begin, end - begin); in strip_double_percent()
167 std::string::size_type pos = part.find("%%"); in strip_double_percent()
168 while (pos != std::string::npos) { in strip_double_percent()
188 const std::pair< std::string::size_type, std::string > placeholder = in init()
190 const std::pair< std::string, int > no_percents = in init()
203 /// \param format The format string.
204 /// \param expansion The format string with any replacements performed so far.
208 /// example, replacing a "%s" string with "foo %s".
209 format::formatter::formatter(const std::string& format, in formatter()
210 const std::string& expansion, in formatter()
211 const std::string::size_type last_pos) : in formatter()
223 /// \param format The format string. The formatters in the string are not
226 format::formatter::formatter(const std::string& format) : in formatter()
242 /// Returns the formatted string.
244 /// \return A string representation of the formatted string.
245 const std::string&
256 format::formatter::operator const std::string&(void) const in operator const std::string&()
264 /// \param value The boolean to inject into the format string.
277 /// \param arg The replacement string.
283 /// placeholders in the input string, or if the placeholder is invalid.
285 format::formatter::replace(const std::string& arg) const in replace()
290 const std::string expansion = _expansion.substr(0, _placeholder_pos) in replace()