CppBlock.cpp
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 #include "CppBlock.h"
25 
26 #include <boost/format.hpp>
27 
28 using namespace armarx;
29 
31 {
32 }
33 
35  line(s)
36 {
37 
38 }
39 
41  nestedBlock(b)
42 {
43 
44 }
45 
47 {
48  writer->body.line(line);
49 }
50 
52 {
53  nestedBlock->writeCpp(writer);
54 }
55 
56 void CppBlock::writeCpp(const CppWriterPtr& writer)
57 {
58  writer->body.startBlock();
59  for (const auto& entry : entries)
60  {
61  entry->writeCpp(writer);
62  }
63  writer->body.endBlock();
64 }
65 
67 {
68  return line;
69 }
70 
72 {
73  return nestedBlock->getAsSingleLine();
74 }
75 
77 {
78  std::stringstream ss;
79  ss << "{ ";
80 
81  for (const auto& entry : entries)
82  {
83  ss << entry->getAsSingleLine() << " ";
84  }
85 
86  ss << "}";
87  return ss.str();
88 }
89 
90 void CppBlock::addLine(const std::string& line)
91 {
93  entries.push_back(t);
94 }
95 
96 void CppBlock::addLine(const boost::basic_format<char>& line)
97 {
98  addLine(boost::str(line));
99 }
100 
101 size_t CppBlock::size() const
102 {
103  return entries.size();
104 }
105 
106 void CppBlock::addCommentLine(const std::string& line)
107 {
108  addLine("//" + line);
109 }
110 
111 void CppBlock::addCommentLine(const boost::basic_format<char>& line)
112 {
113  addLine("//" + boost::str(line));
114 }
115 
116 void CppBlock::addCommentLines(const std::vector<std::string>& lines)
117 {
118  addLine("/*");
119  for (const auto& line : lines)
120  {
121  addLine(" * " + line);
122  }
123  addLine(" */");
124 }
125 
126 void CppBlock::addCommentLines(const std::vector<boost::basic_format<char>>& lines)
127 {
128  addLine("/*");
129  for (const auto& line : lines)
130  {
131  addLine(" * " + boost::str(line));
132  }
133  addLine(" */");
134 }
135 
136 void CppBlock::addBlock(const CppBlockPtr& block)
137 {
139  entries.push_back(t);
140 }
141 
143 {
144  for (const auto& entry : block->entries)
145  {
146  addEntry(entry);
147  }
148 }
149 
150 void CppBlock::addLineAsBlock(const std::string& line)
151 {
152  CppBlockPtr b = std::make_shared<CppBlock>();
153  b->addLine(line);
154  this->addBlock(b);
155 }
156 
158 {
159  entries.push_back(entry);
160 }
161 
163 {
165  for (const auto& entry : block1->entries)
166  {
167  ret->addEntry(entry);
168  }
169 
170  for (const auto& entry : block2->entries)
171  {
172  ret->addEntry(entry);
173  }
174  return ret;
175 }
str
std::string str(const T &t)
Definition: UserAssistedSegmenterGuiWidgetController.cpp:42
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:21
CppBlock.h
armarx::CppBlockPtr
std::shared_ptr< CppBlock > CppBlockPtr
Definition: CppBlock.h:35
armarx::CppBlockEntryPtr
std::shared_ptr< CppBlockEntry > CppBlockEntryPtr
Definition: CppBlock.h:38
armarx::CppBlock::getAsSingleLine
std::string getAsSingleLine()
Definition: CppBlock.cpp:76
armarx::CppBlock::size
size_t size() const
Definition: CppBlock.cpp:101
armarx::CppBlock::MergeBlocks
static CppBlockPtr MergeBlocks(const CppBlockPtr &block1, const CppBlockPtr &block2)
Definition: CppBlock.cpp:162
armarx::CppBlock::addEntry
void addEntry(const CppBlockEntryPtr &entry)
Definition: CppBlock.cpp:157
armarx::CppBlock::addBlock
void addBlock(const CppBlockPtr &block)
Definition: CppBlock.cpp:136
armarx::CppBlockBlockEntry::getAsSingleLine
virtual std::string getAsSingleLine() override
Definition: CppBlock.cpp:71
armarx::CppBlock::entries
std::vector< CppBlockEntryPtr > entries
Definition: CppBlock.h:100
armarx::CppBlock::CppBlock
CppBlock()
Definition: CppBlock.cpp:30
armarx::CppBlockBlockEntry
Definition: CppBlock.h:61
armarx::CppBlock::addCommentLine
void addCommentLine(const std::string &line)
Definition: CppBlock.cpp:106
armarx::CppBlock::addLine
void addLine(const std::string &line)
Definition: CppBlock.cpp:90
armarx::CppBlockStringEntry::getAsSingleLine
virtual std::string getAsSingleLine() override
Definition: CppBlock.cpp:66
armarx::CppBlockStringEntry
Definition: CppBlock.h:49
armarx::CppBlockStringEntry::CppBlockStringEntry
CppBlockStringEntry(const std::string &)
Definition: CppBlock.cpp:34
armarx::CppBlock::appendBlock
void appendBlock(const CppBlockPtr &block)
Definition: CppBlock.cpp:142
armarx::CppBlockBlockEntry::CppBlockBlockEntry
CppBlockBlockEntry(const CppBlockPtr &)
Definition: CppBlock.cpp:40
armarx::CppBlock::writeCpp
void writeCpp(const CppWriterPtr &writer)
Definition: CppBlock.cpp:56
armarx::CppBlock::addLineAsBlock
void addLineAsBlock(const std::string &line)
Definition: CppBlock.cpp:150
armarx::CppBlockStringEntry::writeCpp
virtual void writeCpp(const CppWriterPtr &writer) override
Definition: CppBlock.cpp:46
armarx::CppBlockBlockEntry::writeCpp
virtual void writeCpp(const CppWriterPtr &writer) override
Definition: CppBlock.cpp:51
armarx::CppBlock::addCommentLines
void addCommentLines(const std::vector< std::string > &lines)
Definition: CppBlock.cpp:116
armarx::CppWriterPtr
std::shared_ptr< CppWriter > CppWriterPtr
Definition: CppWriter.h:35
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28