1 mike 1.1 /*
2 **==============================================================================
3 **
4 ** Open Management Infrastructure (OMI)
5 **
6 ** Copyright (c) Microsoft Corporation
7 **
8 ** Licensed under the Apache License, Version 2.0 (the "License"); you may not
9 ** use this file except in compliance with the License. You may obtain a copy
10 ** of the License at
11 **
12 ** http://www.apache.org/licenses/LICENSE-2.0
13 **
14 ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 ** MERCHANTABLITY OR NON-INFRINGEMENT.
18 **
19 ** See the Apache 2 License for the specific language governing permissions
20 ** and limitations under the License.
21 **
22 mike 1.1 **==============================================================================
23 */
24
25 #include "ut.h"
26 #include "strutil.h"
27
28 using namespace std;
29
30 namespace ut
31 {
32
33 std::string StrToChar(const String& str)
34 {
35 string res;
36
37 res.resize(str.size());
38 for (size_t i = 0; i < str.size(); i++)
39 {
40 res[i] = (char)str[i];
41 }
42 return res;
43 mike 1.1 }
44
|
46 mike 1.1 {
47 String line = str;
48 String::size_type pos = line.find( delim );
49
50 while ( pos != String::npos ){
51 res.push_back(line.substr( 0, pos ));
52 line.erase( 0, pos + 1 );
53 pos = line.find( delim );
54 }
55
56 // last item - if it's not empty
57 if (!line.empty() )
58 res.push_back( line );
59 }
60
61 String ArrayToString(const std::vector<String>& ar)
62 {
63 String res;
64
65 for (size_t i = 0; i < ar.size(); i++)
66 {
67 mike 1.1 res += ar[i];
68
69 if ((i+1) < ar.size())
|