GenerateInfo.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5  * Karlsruhe Institute of Technology (KIT), all rights reserved.
6  *
7  * ArmarX is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  * ArmarX is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * @author Fabian Peller-Konrad (fabian dot peller-konrad at kit dot edu)
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #pragma once
25 
26 // STD/STL
27 #include <memory>
28 #include <string>
29 #include <vector>
30 
31 #include <SimoxUtility/algorithm/string.h>
33 
35 {
36  /// A top-level struct for type-generation information
37  struct GenerateInfo
38  {
39  std::string typeName;
40  std::string definedIn;
41  std::string doc_brief;
42  std::string doc_author;
43 
44 
45  std::string getNameWithoutNamespace() const
46  {
47  std::vector<std::string> split = simox::alg::split(typeName, "::");
48  return split[split.size() -1];
49  }
50 
51  std::vector<std::string> getTemplates() const
52  {
53  auto first = typeName.find("<");
54  if (first == std::string::npos)
55  {
56  return {};
57  }
58 
59  auto last = typeName.find(">");
60  ARMARX_CHECK_NOT_EQUAL(last, std::string::npos);
61 
62  return simox::alg::split(typeName.substr(first,last-first), ",");
63  }
64 
65  std::vector<std::string> getNamespaces() const
66  {
67  std::vector<std::string> split = simox::alg::split(typeName, "::");
68  std::vector<std::string> namespaces(split);
69  namespaces.pop_back();
70  return namespaces;
71  }
72  };
73 }
ARMARX_CHECK_NOT_EQUAL
#define ARMARX_CHECK_NOT_EQUAL(lhs, rhs)
This macro evaluates whether lhs is inequal (!=) rhs and if it turns out to be false it will throw an...
Definition: ExpressionException.h:137
armarx::aron::typereader::GenerateInfo::definedIn
std::string definedIn
Definition: GenerateInfo.h:40
armarx::aron::typereader
Definition: GenerateInfo.h:34
armarx::aron::typereader::GenerateInfo::getTemplates
std::vector< std::string > getTemplates() const
Definition: GenerateInfo.h:51
armarx::aron::typereader::GenerateInfo::getNameWithoutNamespace
std::string getNameWithoutNamespace() const
Definition: GenerateInfo.h:45
armarx::aron::typereader::GenerateInfo::typeName
std::string typeName
Definition: GenerateInfo.h:39
armarx::aron::typereader::GenerateInfo
A top-level struct for type-generation information.
Definition: GenerateInfo.h:37
ExpressionException.h
armarx::aron::typereader::GenerateInfo::doc_brief
std::string doc_brief
Definition: GenerateInfo.h:41
armarx::aron::typereader::GenerateInfo::doc_author
std::string doc_author
Definition: GenerateInfo.h:42
armarx::aron::typereader::GenerateInfo::getNamespaces
std::vector< std::string > getNamespaces() const
Definition: GenerateInfo.h:65
armarx::split
std::vector< std::string > split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
Definition: StringHelpers.cpp:36