open-license-manager
2014-04-13 5b35fd450ef78c3be506ca3fc22c3f431ae5e562
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * StringUtils.cpp
 *
 *  Created on: Apr 8, 2014
 *      Author: devel
 */
 
#include <cctype> //toupper
#include "StringUtils.h"
#include <iostream>
#include <string>
#include <algorithm>
 
namespace license {
using namespace std;
 
string trim_copy(const string& string_to_trim) {
    std::string::const_iterator it = string_to_trim.begin();
    while (it != string_to_trim.end() && isspace(*it))
        it++;
 
    std::string::const_reverse_iterator rit = string_to_trim.rbegin();
    while (rit.base() != it && isspace(*rit))
        rit++;
 
    return std::string(it, rit.base());
}
 
string toupper_copy(const string& lowercase) {
    string cp(lowercase);
    std::transform(cp.begin(), cp.end(), cp.begin(), (int(*)(int))toupper);
    return cp;
}
 
} /* namespace license */