conversion.h 1.11 KB
Newer Older
1
2
#pragma once

jbeder's avatar
jbeder committed
3
4
5
6
#ifndef CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66


7
#include "null.h"
8
9
10
11
12
#include <string>
#include <sstream>

namespace YAML
{
13
	inline bool Convert(const std::string& input, std::string& output) {
14
15
16
		output = input;
		return true;
	}
jbeder's avatar
jbeder committed
17
	
18
19
20
21
22
23
	bool Convert(const std::string& input, bool& output);
	bool Convert(const std::string& input, _Null& output);
	
#define YAML_MAKE_STREAM_CONVERT(type) \
	inline bool Convert(const std::string& input, type& output) { \
		std::stringstream stream(input); \
24
25
		stream.unsetf(std::ios::dec); \
		return stream >> output; \
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
	}
	
	YAML_MAKE_STREAM_CONVERT(char)
	YAML_MAKE_STREAM_CONVERT(unsigned char)
	YAML_MAKE_STREAM_CONVERT(int)
	YAML_MAKE_STREAM_CONVERT(unsigned int)
	YAML_MAKE_STREAM_CONVERT(short)
	YAML_MAKE_STREAM_CONVERT(unsigned short)
	YAML_MAKE_STREAM_CONVERT(long)
	YAML_MAKE_STREAM_CONVERT(unsigned long)
	YAML_MAKE_STREAM_CONVERT(float)
	YAML_MAKE_STREAM_CONVERT(double)
	YAML_MAKE_STREAM_CONVERT(long double)
	
#undef YAML_MAKE_STREAM_CONVERT
41
}
jbeder's avatar
jbeder committed
42
43

#endif // CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66