CppEnum.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 <vector>
28
29#include <boost/format/format_fwd.hpp>
30
31#include "CppWriter.h"
32#include "MetaEnum.h"
33
34namespace armarx
35{
36 class CppEnumField;
37 using CppEnumFieldPtr = std::shared_ptr<CppEnumField>;
38
40 {
41 public:
42 CppEnumField(const std::string& name);
43 CppEnumField(const std::string& name, int value);
44
45 void writeCpp(const CppWriterPtr& writer, bool addComma = false);
46
47 private:
48 std::string name;
49 int value = -1;
50 bool hasValue = false;
51 };
52
53 class CppEnum;
54 using CppEnumPtr = std::shared_ptr<CppEnum>;
55
56 class CppEnum : public MetaEnum
57 {
58 public:
59 CppEnum(const std::vector<std::string> namespaces, const std::string& name);
60 CppEnum(const std::vector<std::string> namespaces,
61 const std::string& name,
62 const std::vector<CppEnumFieldPtr>& fields);
63
64 void addField(const CppEnumFieldPtr&);
65
66 std::vector<std::string> getNamespaces() const;
67
68 void write(const MetaWriterPtr& writer) override;
69 void writeCpp(const CppWriterPtr& writer);
70
71 private:
72 std::vector<std::string> namespaces;
73 std::vector<CppEnumFieldPtr> fields;
74 };
75} // namespace armarx
void writeCpp(const CppWriterPtr &writer, bool addComma=false)
Definition CppEnum.cpp:43
CppEnumField(const std::string &name)
Definition CppEnum.cpp:33
CppEnum(const std::vector< std::string > namespaces, const std::string &name)
Definition CppEnum.cpp:52
void writeCpp(const CppWriterPtr &writer)
Definition CppEnum.cpp:84
std::vector< std::string > getNamespaces() const
Definition CppEnum.cpp:78
void write(const MetaWriterPtr &writer) override
Definition CppEnum.cpp:65
void addField(const CppEnumFieldPtr &)
Definition CppEnum.cpp:72
std::string name
Definition MetaEnum.h:49
MetaEnum(const std::string &name)
Definition MetaEnum.cpp:33
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< MetaWriter > MetaWriterPtr
Definition MetaWriter.h:37
std::shared_ptr< CppEnum > CppEnumPtr
Definition CppEnum.h:54
std::shared_ptr< CppWriter > CppWriterPtr
Definition CppWriter.h:35
std::shared_ptr< CppEnumField > CppEnumFieldPtr
Definition CppEnum.h:37