hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
NameValueMass.cpp
Go to the documentation of this file.
1 #include <NameValueMass.h>
2 #include <stdlib.h>
3 
5 {
6  unsigned int valuePos = 0;
7  if (str)
8  {
9  unsigned int i = 0;
10  while(str[i] != 0)
11  {
12  if (str[i] == ',')
13  {
14  if (i > valuePos + 1)
15  {
16  insertNameValue(str + valuePos, i - valuePos);
17  }
18  i++;
19  valuePos = i;
20  continue;
21  }
22  i++;
23  }
24  if (i > valuePos + 1)
25  {
26  insertNameValue(str + valuePos, i - valuePos);
27  }
28  }
29 }
30 
31 void NameValueMass::insertNameValue(const char *str, unsigned int len)
32 {
33  unsigned int i = 0;
34  std::string name;
35  std::string value;
36  bool isName = true;
37  while(i < len)
38  {
39  if (str[i] == '=' && isName)
40  {
41  i++;
42  isName = false;
43  continue;
44  }
45  if(isName)
46  {
47  name += str[i];
48  }
49  else
50  {
51  value += str[i];
52  }
53  i++;
54  }
55  insert(std::pair<std::string, std::string>(name, value));
56 }
57 
58 const char *NameValueMass::getStrVal(const char *name)
59 {
60  const char *ret = NULL;
61  if(name)
62  {
63  internalIter = find(name);
64  if (internalIter != end() && operator[](name).size() > 0)
65  {
66  ret = operator[](name).c_str();
67  }
68  }
69  return ret;
70 }
71 
73 {
74 }