This function breaks down a descriptive string into its components. For details see class reference.
- Parameters
-
buffer | string which should be broekn into pieces |
- Returns
- A vector<Description> containing all the descriptions found. The first entry contains the Description members name and comment, corresponding to the service or command name the Description list is for and its corresponding description.
Definition at line 82 of file Description.cc.
References comment, name, Tools::Trim(), and unit.
Referenced by DimDescriptions::HandleServiceDesc(), DimServiceInfoList::infoHandler(), EventImp::Print(), and ServiceList::ProcessServiceList().
84 const size_t p0 =
buffer.find_first_of(
'=');
86 const string svc =
buffer.substr(0, p0);
87 const string desc =
buffer.substr(p0+1);
89 const size_t p = desc.find_first_of(
'|');
92 const string d =
Trim(desc.substr(0, p));
94 vector<Description> vec;
95 vec.emplace_back(svc, d);
101 stringstream stream(desc.substr(p+1));
102 while (getline(stream, buf,
'|'))
107 const size_t p1 = buf.find_first_of(
':');
109 const string comment = p1==string::npos ?
"" : buf.substr(p1+1);
110 if (p1!=string::npos)
113 const size_t p2 = buf.find_last_of(
'[');
114 const size_t p3 = buf.find_last_of(
']');
116 const bool hasunit = p2<p3 && p2!=string::npos;
118 const string unit = hasunit ? buf.substr(p2+1, p3-p2-1) :
"";
119 const string name = hasunit ? buf.substr(0, p2) : buf;
121 vec.emplace_back(name, comment, unit);