FACT++  1.0
vector< State > State::SplitStates ( const std::string &  buffer)
static

Time of state change.

This function breaks down a descriptive string into its components. For details see class reference.

Parameters
bufferstring which should be broekn into pieces
Returns
A vector<State> containing all the states found.

Definition at line 58 of file State.cc.

References comment, Compare(), index, and name.

Referenced by DimDescribedState::HandleDesc(), and DimServiceInfoList::infoHandler().

59 {
60  vector<State> vec;
61 
62  string buf;
63  stringstream stream(buffer);
64  while (getline(stream, buf, '\n'))
65  {
66  if (buf.empty())
67  continue;
68 
69  const size_t p1 = buf.find_first_of(':');
70  const size_t p2 = buf.find_first_of('=');
71 
72  stringstream s(buf.substr(0, p1));
73 
74  int index;
75  s >> index;
76 
77  const string name = buf.substr(p1+1, p2-p1-1);
78  const string comment = p2==string::npos ? "" : buf.substr(p2+1);
79 
80  vec.emplace_back(index, name, comment);
81  }
82 
83  sort(vec.begin(), vec.end(), State::Compare);
84 
85  return vec;
86 }
std::string comment
Name (e.g. &#39;Connected&#39;)
Definition: State.h:13
int index
Definition: State.h:11
static bool Compare(const State &i, const State &j)
Definition: State.h:18
int buffer[BUFFSIZE]
Definition: db_dim_client.c:14
std::string name
Index (e.g. 1)
Definition: State.h:12

+ Here is the call graph for this function:

+ Here is the caller graph for this function: