Switch to unified view

a/src/smallut.h b/src/smallut.h
...
...
61
extern int stringuppercmp(const std::string& alreadyupper,
61
extern int stringuppercmp(const std::string& alreadyupper,
62
                          const std::string& s2);
62
                          const std::string& s2);
63
63
64
extern void stringtolower(std::string& io);
64
extern void stringtolower(std::string& io);
65
extern std::string stringtolower(const std::string& io);
65
extern std::string stringtolower(const std::string& io);
66
extern void stringtoupper(std::string& io);
67
extern std::string stringtoupper(const std::string& io);
66
68
67
// Is one string the end part of the other ?
69
// Is one string the end part of the other ?
68
extern int stringisuffcmp(const std::string& s1, const std::string& s2);
70
extern int stringisuffcmp(const std::string& s1, const std::string& s2);
69
71
70
// Divine language from locale
72
// Divine language from locale
...
...
139
extern void trimstring(std::string& s, const char *ws = " \t");
141
extern void trimstring(std::string& s, const char *ws = " \t");
140
142
141
/** Escape things like < or & by turning them into entities */
143
/** Escape things like < or & by turning them into entities */
142
extern std::string escapeHtml(const std::string& in);
144
extern std::string escapeHtml(const std::string& in);
143
145
146
/** Double-quote and escape to produce C source code string (prog generation) */
147
extern std::string makeCString(const std::string& in);
148
144
/** Replace some chars with spaces (ie: newline chars). */
149
/** Replace some chars with spaces (ie: newline chars). */
145
extern std::string neutchars(const std::string& str, const std::string& chars);
150
extern std::string neutchars(const std::string& str, const std::string& chars);
146
extern void neutchars(const std::string& str, std::string& out,
151
extern void neutchars(const std::string& str, std::string& out,
147
                      const std::string& chars);
152
                      const std::string& chars);
148
153
...
...
186
{
191
{
187
    if (s.length() && s.length() < len) {
192
    if (s.length() && s.length() < len) {
188
        s = s.insert(0, len - s.length(), '0');
193
        s = s.insert(0, len - s.length(), '0');
189
    }
194
    }
190
}
195
}
196
197
// A class to solve platorm/compiler issues for simple regex
198
// matches. Uses the appropriate native lib under the hood.
199
// This always uses extended regexp syntax.
200
class SimpleRegexp {
201
public:
202
    enum Flags {SRE_NONE = 0, SRE_ICASE = 1, SRE_NOSUB = 2};
203
    /// @param nmatch must be >= the number of parenthesed subexp in exp
204
    SimpleRegexp(const std::string& exp, int flags, int nmatch = 0);
205
    ~SimpleRegexp();
206
    /// Match input against exp, return true if matches
207
    bool simpleMatch(const std::string& val) const;
208
    /// After simpleMatch success, get nth submatch, 0 is the whole
209
    /// match, 1 first parentheses, etc.
210
    std::string getMatch(const std::string& val, int matchidx) const;
211
    /// Calls simpleMatch()
212
    bool operator() (const std::string& val) const;
213
    /// Check after construction
214
    bool ok() const;
215
    
216
    class Internal;
217
private:
218
    Internal *m;
219
};
191
220
192
// Code for static initialization of an stl map. Somewhat like Boost.assign.
221
// Code for static initialization of an stl map. Somewhat like Boost.assign.
193
// Ref: http://stackoverflow.com/questions/138600/initializing-a-static-stdmapint-int-in-c
222
// Ref: http://stackoverflow.com/questions/138600/initializing-a-static-stdmapint-int-in-c
194
// Example use: map<int, int> m = create_map<int, int> (1,2) (3,4) (5,6) (7,8);
223
// Example use: map<int, int> m = create_map<int, int> (1,2) (3,4) (5,6) (7,8);
195
224