CMakeWriter.cpp
Go to the documentation of this file.
1 #include "CMakeWriter.h"
2 
3 using namespace armarx;
4 
6 {
7  indent = 0;
8  indentChars = " ";
9  lastLineType = Empty;
10 }
11 
12 
13 
14 void CMakeWriter::startBlock(const std::string& line)
15 {
16  this->line(line);
17  // this->line("{");
18  indent++;
19  lastLineType = StartBlock;
20 }
21 
22 
23 void CMakeWriter::endBlock(const std::string& line)
24 {
25  indent--;
26  this->line(std::string("}") + line);
27  lastLineType = EndBlock;
28 }
29 
30 void CMakeWriter::endBlockComment(std::string comment)
31 {
32  indent--;
33  this->line(std::string("# ") + comment);
34  lastLineType = EndBlock;
35 }
36 
38 {
39  lineInternal("", indent);
40 }
41 
42 void CMakeWriter::line(const std::string& line)
43 {
44  lineInternal(line, indent);
45 }
46 
47 void CMakeWriter::line(const std::string& line, int indentDelta)
48 {
49  lineInternal(line, indent + indentDelta);
50 }
51 
53 {
54  return ss.str();
55 }
56 
58 {
59  return lastLineType;
60 }
61 
62 void CMakeWriter::lineInternal(const std::string& line, int indent)
63 {
64  for (int i = 0; i < indent; i++)
65  {
66  ss << indentChars;
67  }
68 
69  ss << line << std::endl;
70  lastLineType = line.empty() ? Empty : Normal;
71 }
armarx::CMakeWriter::CMakeWriter
CMakeWriter()
Definition: CMakeWriter.cpp:5
armarx::CMakeWriter::getString
std::string getString()
Definition: CMakeWriter.cpp:52
armarx::CMakeWriter::LineType
LineType
Definition: CMakeWriter.h:15
armarx::CMakeWriter::line
void line()
Definition: CMakeWriter.cpp:37
armarx::CMakeWriter::endBlock
void endBlock(const std::string &line)
Definition: CMakeWriter.cpp:23
armarx::CMakeWriter::Empty
@ Empty
Definition: CMakeWriter.h:15
armarx::CMakeWriter::Normal
@ Normal
Definition: CMakeWriter.h:15
armarx::CMakeWriter::endBlockComment
void endBlockComment(std::string comment)
Definition: CMakeWriter.cpp:30
armarx::CMakeWriter::EndBlock
@ EndBlock
Definition: CMakeWriter.h:15
CMakeWriter.h
armarx::CMakeWriter::getLastLineType
LineType getLastLineType()
Definition: CMakeWriter.cpp:57
armarx::CMakeWriter::StartBlock
@ StartBlock
Definition: CMakeWriter.h:15
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::CMakeWriter::startBlock
void startBlock(const std::string &line)
Definition: CMakeWriter.cpp:14