metadata.h
Go to the documentation of this file.
1 /************************************************************************************
2 * *
3 * Copyright (c) 2014 Axel Menzel <info@axelmenzel.de> *
4 * *
5 * This file is part of RTTR (Run Time Type Reflection) *
6 * License: MIT License *
7 * *
8 * Permission is hereby granted, free of charge, to any person obtaining *
9 * a copy of this software and associated documentation files (the "Software"), *
10 * to deal in the Software without restriction, including without limitation *
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
12 * and/or sell copies of the Software, and to permit persons to whom the *
13 * Software is furnished to do so, subject to the following conditions: *
14 * *
15 * The above copyright notice and this permission notice shall be included in *
16 * all copies or substantial portions of the Software. *
17 * *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *
24 * SOFTWARE. *
25 * *
26 *************************************************************************************/
27 
28 #ifndef __RTTR_METADATA_H__
29 #define __RTTR_METADATA_H__
30 
32 #include "rttr/variant.h"
33 
34 #include <algorithm>
35 #include <string>
36 #include <utility>
37 
38 namespace rttr
39 {
40 
48 {
49  public:
50  metadata(const metadata& other) : _key(other._key), _value(other._value) {}
51  metadata(std::string key, variant value) : _key(std::move(key)), _value(std::move(value)) {}
52  metadata(int key, variant value) : _key(std::move(key)), _value(std::move(value)) {}
53  metadata(metadata&& data) : _key(std::move(data._key)), _value(std::move(data._value)) { data._key = variant(); data._value = variant(); }
54  metadata& operator=(metadata other) { std::swap(_key, other._key); std::swap(_value, other._value); return *this; }
55 
56  variant get_key() const { return _key; }
57  variant get_value() const { return _value; }
58 
59  private:
60  variant _key;
61  variant _value;
62 };
63 
64 } // end namespace rttr
65 
66 #endif // __RTTR_METADATA_H__
The namespace for all rttr components.
Definition: core_prerequisites.h:33
variant get_key() const
Definition: metadata.h:56
metadata(metadata &&data)
Definition: metadata.h:53
metadata(std::string key, variant value)
Definition: metadata.h:51
This class is used to add custom meta data to the binding of a type.
Definition: metadata.h:47
metadata(int key, variant value)
Definition: metadata.h:52
The variant class allows to store data of any type and convert between these types transparently...
Definition: variant.h:125
variant get_value() const
Definition: metadata.h:57
metadata & operator=(metadata other)
Definition: metadata.h:54
#define RTTR_API
Definition: core_prerequisites.h:124
metadata(const metadata &other)
Definition: metadata.h:50