MetaWriter.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package
19 * @author
20 * @date
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24#pragma once
25
26#include <memory>
27#include <sstream>
28#include <string>
29#include <vector>
30
31// Simox
32#include <SimoxUtility/algorithm/string.h>
33
34namespace armarx
35{
36 class MetaWriter;
37 using MetaWriterPtr = std::shared_ptr<MetaWriter>;
38
39 class Lines
40 {
41 public:
49
50 std::string name;
51 std::stringstream ss;
52 std::vector<std::string> lines;
53 int indent = 0;
54
55 Lines() = delete;
56 Lines(const std::string&, const std::string& = " ", const LineType = LineType::Empty);
57
58 void startBlock();
59 void startBlock(const std::string& line);
60 void endBlock();
61 void endBlock(const std::string& line);
62 void endBlockComment(std::string comment);
63
64 void line();
65 void line(const std::string& line, int indentDelta = 0);
66 void lineCheckDuplicate(const std::string& line, int indentDelta = 0);
67 void enforceEmptyLine();
68
70
71 private:
72 void lineInternal(const std::string& line, int indent);
73
74 private:
75 std::string indentChars;
76 LineType lastLineType;
77 };
78
80 {
81 public:
82 MetaWriter(const std::string& doc);
83 virtual ~MetaWriter() = default;
84
85 void lineHeader();
86 void lineFooter();
87
88 std::string getString();
89
90 static void ConvertToTextWithMaxWidth(unsigned int maxTextWidth,
91 const std::vector<std::string>& docLines,
92 std::vector<std::string>& linesOut);
93
94 public:
98
99 protected:
100 std::string fileDoc;
101 };
102} // namespace armarx
Lines::LineType getLastLineType()
Lines()=delete
void startBlock()
void lineCheckDuplicate(const std::string &line, int indentDelta=0)
std::vector< std::string > lines
Definition MetaWriter.h:52
void enforceEmptyLine()
std::stringstream ss
Definition MetaWriter.h:51
std::string name
Definition MetaWriter.h:50
void endBlockComment(std::string comment)
static void ConvertToTextWithMaxWidth(unsigned int maxTextWidth, const std::vector< std::string > &docLines, std::vector< std::string > &linesOut)
MetaWriter(const std::string &doc)
virtual ~MetaWriter()=default
std::string getString()
std::string fileDoc
Definition MetaWriter.h:100
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< MetaWriter > MetaWriterPtr
Definition MetaWriter.h:37