"vscode:/vscode.git/clone" did not exist on "dc82aac759b4bc38d0f41063bc96d9d10ef8ab02"
value.h 2.31 KB
Newer Older
1
2
#ifndef VALUE_VALUE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define VALUE_VALUE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
3
4
5
6
7
8
9

#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif


#include "yaml-cpp/dll.h"
10
#include "yaml-cpp/value/iterator.h"
Jesse Beder's avatar
Jesse Beder committed
11
12
#include "yaml-cpp/value/ptr.h"
#include "yaml-cpp/value/type.h"
13
#include <stdexcept>
14
15
16
17
18
19

namespace YAML
{
	class Value
	{
	public:
20
21
		friend class detail::node_data;
		
22
23
		Value();
		explicit Value(ValueType::value type);
24
25
		template<typename T> explicit Value(const T& rhs);
		Value(const Value& rhs);
26
27
28
29
30
31
		~Value();
		
		ValueType::value Type() const;
		
		// access
		template<typename T> const T as() const;
32
		const std::string& scalar() const;
33
34
		
		// assignment
Jesse Beder's avatar
Jesse Beder committed
35
		bool is(const Value& rhs) const;
36
		template<typename T> Value& operator=(const T& rhs);
37
38
39
40
41
42
43
44
45
46
47
		Value& operator=(const Value& rhs);
		
		// size/iterator
		std::size_t size() const;

		const_iterator begin() const;
		iterator begin();
		
		const_iterator end() const;
		iterator end();
		
Jesse Beder's avatar
Jesse Beder committed
48
49
50
51
		// sequence
		template<typename T> void append(const T& rhs);
		void append(const Value& rhs);
		
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
		// indexing
		template<typename Key> const Value operator[](const Key& key) const;
		template<typename Key> Value operator[](const Key& key);
		template<typename Key> bool remove(const Key& key);

		const Value operator[](const Value& key) const;
		Value operator[](const Value& key);
		bool remove(const Value& key);
		
		const Value operator[](const char *key) const;
		Value operator[](const char *key);
		bool remove(const char *key);

		const Value operator[](char *key) const;
		Value operator[](char *key);
		bool remove(char *key);
68
69
		
	private:
70
		explicit Value(detail::node& node, detail::shared_memory_holder pMemory);
71
		
72
		template<typename T> void Assign(const T& rhs);
73
74
		void Assign(const char *rhs);
		void Assign(char *rhs);
75

76
77
78
79
		void AssignData(const Value& rhs);
		void AssignNode(const Value& rhs);
		
	private:
80
		detail::shared_memory_holder m_pMemory;
81
		detail::node *m_pNode;
82
83
84
85
86
87
	};
	
	int compare(const Value& lhs, const Value& rhs);
	bool operator<(const Value& lhs, const Value& rhs);
	
	bool is(const Value& lhs, const Value& rhs);
88
89
	
	template<typename T>
90
	struct convert;
91
92
}

93
#endif // VALUE_VALUE_H_62B23520_7C8E_11DE_8A39_0800200C9A66