| 223 | } |
| 224 | |
| 225 | std::vector<std::string> EnergyManagementSystemProgram_Impl::lines() const { |
| 226 | //return vector of lines from body |
| 227 | std::vector<std::string> result; |
| 228 | boost::optional<std::string> comment; |
| 229 | std::string whole_line; |
| 230 | |
| 231 | // loop through extensible groups and add ProgramLine to vector result. |
| 232 | auto groups = extensibleGroups(); |
| 233 | |
| 234 | for (auto group = groups.begin(); group != groups.end(); ++group) { |
| 235 | //clear out whole_line |
| 236 | whole_line.clear(); |
| 237 | //get program line content |
| 238 | const auto& line = group->getString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, true); |
| 239 | OS_ASSERT(line); |
| 240 | //add programLine to whole_line |
| 241 | whole_line += line.get(); |
| 242 | //get non-default comments if they exist |
| 243 | comment = group->fieldComment(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, false); |
| 244 | if (comment.is_initialized()) { |
| 245 | //remove space after ! |
| 246 | boost::erase_first(comment.get(), " "); |
| 247 | //add space between end of program line and comment |
| 248 | if (!comment.get().empty()) { |
| 249 | whole_line += " " + comment.get(); |
| 250 | } |
| 251 | } |
| 252 | //add newline character |
| 253 | whole_line += '\n'; |
| 254 | //add whole_line to vector |
| 255 | result.push_back(whole_line); |
| 256 | } |
| 257 | return result; |
| 258 | } |
| 259 | |
| 260 | bool EnergyManagementSystemProgram_Impl::setLines(const std::vector<std::string>& lines) { |
| 261 | //set body of program to input vector of strings |