| 54 | } |
| 55 | |
| 56 | std::string EnergyManagementSystemProgram_Impl::body() const { |
| 57 | //return program body as string |
| 58 | |
| 59 | // loop through extensible groups and add ProgramLine to body string. |
| 60 | std::string body; |
| 61 | boost::optional<std::string> comment; |
| 62 | |
| 63 | auto groups = extensibleGroups(); |
| 64 | for (auto group = groups.begin(); group != groups.end(); ++group) { |
| 65 | //get program line content |
| 66 | const auto& line = group->getString(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, true); |
| 67 | OS_ASSERT(line); |
| 68 | body += line.get(); |
| 69 | //get non-default comments if they exist |
| 70 | comment = group->fieldComment(OS_EnergyManagementSystem_ProgramExtensibleFields::ProgramLine, false); |
| 71 | if (comment.is_initialized()) { |
| 72 | //remove space after ! |
| 73 | boost::erase_first(comment.get(), " "); |
| 74 | //add space between end of program line and comment |
| 75 | if (!comment.get().empty()) { |
| 76 | body += " " + comment.get(); |
| 77 | } |
| 78 | } |
| 79 | //add newline character |
| 80 | body += '\n'; |
| 81 | } |
| 82 | return body; |
| 83 | } |
| 84 | |
| 85 | bool EnergyManagementSystemProgram_Impl::setBody(const std::string& body) { |
| 86 | //set body of program to input string |