Changeset 10381 for trunk/FACT++/src/Description.cc
- Timestamp:
- 04/18/11 10:58:17 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Description.cc
r10349 r10381 43 43 #include <sstream> 44 44 45 #include "tools.h" 46 45 47 using namespace std; 48 49 // -------------------------------------------------------------------------- 50 // 51 //! Construct a Description object 52 //! 53 //! @param n 54 //! Name of the Description, e.g. "temp" 55 //! 56 //! @param c 57 //! Descriptive text of the Description, e.g. "Temperature of the moon" 58 //! 59 //! @param u 60 //! Unit of the Description, e.g. "K" 61 // 62 Description::Description(const string &n, const string &c, const string &u) 63 : name(Trim(n)), comment(Trim(c)), unit(Trim(u)) 64 { 65 } 46 66 47 67 // -------------------------------------------------------------------------- … … 72 92 73 93 vector<Description> vec; 74 vec.push_back(Description(svc, "",d));94 vec.push_back(Description(svc, d)); 75 95 76 96 if (p==string::npos) … … 98 118 const string name = hasunit ? buf.substr(0, p2) : buf; 99 119 100 vec.push_back(Description(name, unit, comment));120 vec.push_back(Description(name, comment, unit)); 101 121 } 102 122 103 123 return vec; 104 124 } 125 126 127 // -------------------------------------------------------------------------- 128 // 129 //! Returns a string with an html formatted text containing the descriptions 130 //! as returned by SplitDescription 131 //! 132 //! @param vec 133 //! vector of Description for the individual arguments. First 134 //! element is the global description of the command or service. 135 //! 136 //! @returns 137 //! string with html formatted text 138 // 139 string Description::GetHtmlDescription(const vector<Description> &vec) 140 { 141 stringstream str; 142 str << '|'; 143 144 str << "<H3>" << vec[0].name << "</H3>"; 145 146 str << "Usage:"; 147 for (vector<Description>::const_iterator i=vec.begin()+1; i!=vec.end(); i++) 148 str << " <font color='maroon'><" << i->name << "></font>"; 149 150 if (vec.size()==1) 151 str << " <no arguments>"; 152 153 str << "<P>" << vec[0].comment << "<P>"; 154 155 str << "<table>"; 156 157 for (vector<Description>::const_iterator i=vec.begin()+1; i!=vec.end(); i++) 158 { 159 str << "<tr>" 160 "<td><font color='maroon'>" << i->name << "</font>"; 161 162 if (i->unit.empty() && !i->comment.empty() && !i->name.empty()) 163 str << ':'; 164 165 str << "</td>"; 166 167 if (!i->unit.empty()) 168 str << "<td><font color='green'>[" << i->unit << "]</font>"; 169 170 if (!i->unit.empty() && !i->comment.empty()) 171 str << ':'; 172 173 str << 174 "</td>" 175 "<td><font color='navy'>" << i->comment << "</font></td>" 176 "</tr>"; 177 } 178 179 str << "</table>"; 180 181 return str.str(); 182 }
Note:
See TracChangeset
for help on using the changeset viewer.