2 // C++ Interface: gm_utils
7 // Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2004
9 // Copyright: See COPYING file that comes with this distribution
25 * @return a copy of the string passed after canonizing it (i.e. '-' and
26 * '.' are transformed in '_').
28 char *canonize_names(const char * name);
32 * @return a copy of the string passed after canonizing it (i.e. '-' and
33 * '.' are transformed in '_').
35 const string canonize_name(const string &name);
38 * @param s the string representing an enum value
39 * @return a copy of the string passed after canonizing it (i.e. '-' and
40 * becomes _MINUS_, '+' becomes _PLUS_)
42 const string canonize_enum(const string &s);
44 const string strip_path(const string &);
45 const string to_upper(const string &);
48 * All multiple options are of type string
49 * @return All multiple options are of type string
51 bool has_multiple_options_all_string();
54 * Has multiple options and at least one is of type string
55 * @return Has multiple options and at least one is of type string
57 bool has_multiple_options_string();
60 * Has multiple options and at least one has a default value
61 * @return Has multiple options and at least one has a default value
63 bool has_multiple_options_with_default();
65 bool has_multiple_options();
66 bool has_multiple_options_with_type();
68 bool has_dependencies();
69 bool has_options_with_type();
70 bool has_options_with_mode();
72 bool has_hidden_options();
73 bool has_options_with_details();
77 * Whether the specified option deals with number
82 bool is_numeric(const gengetopt_option *opt);
85 * Performs word wrapping on the passed string (and return the result in the first
88 * @param wrapped the output parameter
89 * @param from_column the string start from this column
90 * @param second_indent an additional indentation for lines after the
92 * @param orig the original string that must be wrapped
94 void wrap_cstr (string &wrapped, unsigned int from_column, unsigned int second_indent, const string &orig);
97 * Searches for characters which are not newlines.
99 * @param buf where to search for new characters
100 * @param num_of_newlines where the number of newlines
101 * before the first non newline char will be stored
102 * @return the position in the string after the (possible) new line char
104 int not_newlines(const string &buf, int &num_of_newlines);
107 * Function object to print something into a stream (to be used with for_each)
110 struct print_f : public std::unary_function<T, void>
112 print_f(std::ostream& out, const string &s = ", ") : os(out), sep(s) {}
113 void operator() (T x) { os << x << sep; }
119 * Function object to print a pair into two streams (to be used with for_each)
122 struct pair_print_f : public std::unary_function<T, void>
124 pair_print_f(std::ostream& out1, std::ostream& out2, const string &s = ", ") :
125 os1(out1), os2(out2), sep(s) {}
126 void operator() (T x) { os1 << x.first << sep; os2 << x.second << sep;}
127 std::ostream &os1, &os2;