diff --git a/include/yaml-cpp/aliasmanager.h b/include/yaml-cpp/aliasmanager.h index d650269..e90c93d 100644 --- a/include/yaml-cpp/aliasmanager.h +++ b/include/yaml-cpp/aliasmanager.h @@ -1,7 +1,7 @@ #ifndef ALIASMANAGER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define ALIASMANAGER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/anchor.h b/include/yaml-cpp/anchor.h index 175d4d7..433f2fa 100644 --- a/include/yaml-cpp/anchor.h +++ b/include/yaml-cpp/anchor.h @@ -1,7 +1,7 @@ #ifndef ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/contrib/anchordict.h b/include/yaml-cpp/contrib/anchordict.h index 8638aab..e483dc4 100644 --- a/include/yaml-cpp/contrib/anchordict.h +++ b/include/yaml-cpp/contrib/anchordict.h @@ -1,7 +1,7 @@ #ifndef ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/contrib/graphbuilder.h b/include/yaml-cpp/contrib/graphbuilder.h index 7c09fb2..6739a12 100644 --- a/include/yaml-cpp/contrib/graphbuilder.h +++ b/include/yaml-cpp/contrib/graphbuilder.h @@ -1,7 +1,7 @@ #ifndef GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/conversion.h b/include/yaml-cpp/conversion.h index adf72d8..ba7eed1 100644 --- a/include/yaml-cpp/conversion.h +++ b/include/yaml-cpp/conversion.h @@ -1,7 +1,7 @@ #ifndef CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define CONVERSION_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/dll.h b/include/yaml-cpp/dll.h index c09cf6b..ea13840 100644 --- a/include/yaml-cpp/dll.h +++ b/include/yaml-cpp/dll.h @@ -1,7 +1,7 @@ #ifndef DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define DLL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/emitfromevents.h b/include/yaml-cpp/emitfromevents.h index 4f9badc..e11ae64 100644 --- a/include/yaml-cpp/emitfromevents.h +++ b/include/yaml-cpp/emitfromevents.h @@ -1,7 +1,7 @@ #ifndef EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/emitter.h b/include/yaml-cpp/emitter.h index 4cedb0e..eebdd4c 100644 --- a/include/yaml-cpp/emitter.h +++ b/include/yaml-cpp/emitter.h @@ -1,7 +1,7 @@ #ifndef EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/emittermanip.h b/include/yaml-cpp/emittermanip.h index 1dc5766..5c63419 100644 --- a/include/yaml-cpp/emittermanip.h +++ b/include/yaml-cpp/emittermanip.h @@ -1,7 +1,7 @@ #ifndef EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif @@ -127,12 +127,12 @@ namespace YAML } struct _Binary { - _Binary(const char *data_, std::size_t size_): data(data_), size(size_) {} - const char *data; + _Binary(const unsigned char *data_, std::size_t size_): data(data_), size(size_) {} + const unsigned char *data; std::size_t size; }; - inline _Binary Binary(const char *data, std::size_t size) { + inline _Binary Binary(const unsigned char *data, std::size_t size) { return _Binary(data, size); } } diff --git a/include/yaml-cpp/eventhandler.h b/include/yaml-cpp/eventhandler.h index 80afdb4..3173a1f 100644 --- a/include/yaml-cpp/eventhandler.h +++ b/include/yaml-cpp/eventhandler.h @@ -1,7 +1,7 @@ #ifndef EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/exceptions.h b/include/yaml-cpp/exceptions.h index e940499..394d586 100644 --- a/include/yaml-cpp/exceptions.h +++ b/include/yaml-cpp/exceptions.h @@ -1,7 +1,7 @@ #ifndef EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EXCEPTIONS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/iterator.h b/include/yaml-cpp/iterator.h index 2397db9..400ee34 100644 --- a/include/yaml-cpp/iterator.h +++ b/include/yaml-cpp/iterator.h @@ -1,7 +1,7 @@ #ifndef ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/ltnode.h b/include/yaml-cpp/ltnode.h index cf85435..30b4f95 100644 --- a/include/yaml-cpp/ltnode.h +++ b/include/yaml-cpp/ltnode.h @@ -1,7 +1,7 @@ #ifndef LTNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define LTNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/mark.h b/include/yaml-cpp/mark.h index 09057da..7c80fbc 100644 --- a/include/yaml-cpp/mark.h +++ b/include/yaml-cpp/mark.h @@ -1,7 +1,7 @@ #ifndef MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/node.h b/include/yaml-cpp/node.h index ff752c4..2c0a686 100644 --- a/include/yaml-cpp/node.h +++ b/include/yaml-cpp/node.h @@ -1,7 +1,7 @@ #ifndef NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif @@ -77,7 +77,9 @@ namespace YAML // specific to maps const Node *FindValue(const char *key) const; + const Node *FindValue(char *key) const; const Node& operator [] (const char *key) const; + const Node& operator [] (char *key) const; // for tags const std::string& Tag() const { return m_tag; } diff --git a/include/yaml-cpp/nodeimpl.h b/include/yaml-cpp/nodeimpl.h index d26968a..6ea24e4 100644 --- a/include/yaml-cpp/nodeimpl.h +++ b/include/yaml-cpp/nodeimpl.h @@ -1,7 +1,7 @@ #ifndef NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif @@ -68,10 +68,18 @@ namespace YAML inline const Node *Node::FindValue(const char *key) const { return FindValue(std::string(key)); } + + inline const Node *Node::FindValue(char *key) const { + return FindValue(std::string(key)); + } inline const Node& Node::operator [] (const char *key) const { return GetValue(std::string(key)); } + + inline const Node& Node::operator [] (char *key) const { + return GetValue(std::string(key)); + } } #endif // NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/include/yaml-cpp/nodereadimpl.h b/include/yaml-cpp/nodereadimpl.h index 9ad5b83..6838dc5 100644 --- a/include/yaml-cpp/nodereadimpl.h +++ b/include/yaml-cpp/nodereadimpl.h @@ -1,7 +1,7 @@ #ifndef NODEREADIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define NODEREADIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/nodeutil.h b/include/yaml-cpp/nodeutil.h index 98ea4fa..d0c01d2 100644 --- a/include/yaml-cpp/nodeutil.h +++ b/include/yaml-cpp/nodeutil.h @@ -1,7 +1,7 @@ #ifndef NODEUTIL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define NODEUTIL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/noncopyable.h b/include/yaml-cpp/noncopyable.h index 1614b68..8e61e43 100644 --- a/include/yaml-cpp/noncopyable.h +++ b/include/yaml-cpp/noncopyable.h @@ -1,7 +1,7 @@ #ifndef NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define NONCOPYABLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/null.h b/include/yaml-cpp/null.h index 9c7986b..c3450ee 100644 --- a/include/yaml-cpp/null.h +++ b/include/yaml-cpp/null.h @@ -1,7 +1,7 @@ #ifndef NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/ostream.h b/include/yaml-cpp/ostream.h index 90258ba..65839b1 100644 --- a/include/yaml-cpp/ostream.h +++ b/include/yaml-cpp/ostream.h @@ -1,7 +1,7 @@ #ifndef OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define OSTREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/parser.h b/include/yaml-cpp/parser.h index 32a2d16..3463cc3 100644 --- a/include/yaml-cpp/parser.h +++ b/include/yaml-cpp/parser.h @@ -1,7 +1,7 @@ #ifndef PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/stlemitter.h b/include/yaml-cpp/stlemitter.h index 74dce1b..f8ff20e 100644 --- a/include/yaml-cpp/stlemitter.h +++ b/include/yaml-cpp/stlemitter.h @@ -1,7 +1,7 @@ #ifndef STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/stlnode.h b/include/yaml-cpp/stlnode.h index 8d50f7f..40d4ae7 100644 --- a/include/yaml-cpp/stlnode.h +++ b/include/yaml-cpp/stlnode.h @@ -1,7 +1,7 @@ #ifndef STLNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define STLNODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/traits.h b/include/yaml-cpp/traits.h index 32a3155..09eead4 100644 --- a/include/yaml-cpp/traits.h +++ b/include/yaml-cpp/traits.h @@ -1,7 +1,7 @@ #ifndef TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/include/yaml-cpp/yaml.h b/include/yaml-cpp/yaml.h index 674430e..d2ca43b 100644 --- a/include/yaml-cpp/yaml.h +++ b/include/yaml-cpp/yaml.h @@ -1,7 +1,7 @@ #ifndef YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/collectionstack.h b/src/collectionstack.h index 5274546..4a986bc 100644 --- a/src/collectionstack.h +++ b/src/collectionstack.h @@ -1,7 +1,7 @@ #ifndef COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/contrib/graphbuilderadapter.h b/src/contrib/graphbuilderadapter.h index 4f0b80c..3ef8ab6 100644 --- a/src/contrib/graphbuilderadapter.h +++ b/src/contrib/graphbuilderadapter.h @@ -1,7 +1,7 @@ #ifndef GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/directives.h b/src/directives.h index 2fa6f62..a3308f7 100644 --- a/src/directives.h +++ b/src/directives.h @@ -1,7 +1,7 @@ #ifndef DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/emitterstate.h b/src/emitterstate.h index 9c8136e..90be656 100644 --- a/src/emitterstate.h +++ b/src/emitterstate.h @@ -1,7 +1,7 @@ #ifndef EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/emitterutils.cpp b/src/emitterutils.cpp index 5bc0ba9..95a01fa 100644 --- a/src/emitterutils.cpp +++ b/src/emitterutils.cpp @@ -128,6 +128,9 @@ namespace YAML } bool IsValidPlainScalar(const std::string& str, bool inFlow, bool allowOnlyAscii) { + if(str.empty()) + return false; + // first check the start const RegEx& start = (inFlow ? Exp::PlainScalarInFlow() : Exp::PlainScalar()); if(!start.Matches(str)) @@ -344,7 +347,7 @@ namespace YAML return true; } - bool WriteBinary(ostream& out, const char *data, std::size_t size) + bool WriteBinary(ostream& out, const unsigned char *data, std::size_t size) { static const char encoding[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; const char PAD = '='; diff --git a/src/emitterutils.h b/src/emitterutils.h index 5b3de82..27ca115 100644 --- a/src/emitterutils.h +++ b/src/emitterutils.h @@ -1,7 +1,7 @@ #ifndef EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif @@ -22,7 +22,7 @@ namespace YAML bool WriteAnchor(ostream& out, const std::string& str); bool WriteTag(ostream& out, const std::string& str, bool verbatim); bool WriteTagWithPrefix(ostream& out, const std::string& prefix, const std::string& tag); - bool WriteBinary(ostream& out, const char *data, std::size_t size); + bool WriteBinary(ostream& out, const unsigned char *data, std::size_t size); } } diff --git a/src/exp.h b/src/exp.h index 0200d25..703641a 100644 --- a/src/exp.h +++ b/src/exp.h @@ -1,7 +1,7 @@ #ifndef EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/indentation.h b/src/indentation.h index 89d68df..25f684f 100644 --- a/src/indentation.h +++ b/src/indentation.h @@ -1,7 +1,7 @@ #ifndef INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/iterpriv.h b/src/iterpriv.h index 8e2ab22..c511e8a 100644 --- a/src/iterpriv.h +++ b/src/iterpriv.h @@ -1,7 +1,7 @@ #ifndef ITERPRIV_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define ITERPRIV_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/nodebuilder.h b/src/nodebuilder.h index eba403a..9c1d16a 100644 --- a/src/nodebuilder.h +++ b/src/nodebuilder.h @@ -1,7 +1,7 @@ #ifndef NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/nodeownership.h b/src/nodeownership.h index aae9b99..6987081 100644 --- a/src/nodeownership.h +++ b/src/nodeownership.h @@ -1,7 +1,7 @@ #ifndef NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define NODE_OWNERSHIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/ptr_stack.h b/src/ptr_stack.h index 03dd364..bf454fb 100644 --- a/src/ptr_stack.h +++ b/src/ptr_stack.h @@ -1,7 +1,7 @@ #ifndef PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/ptr_vector.h b/src/ptr_vector.h index d1742a3..7b936cb 100644 --- a/src/ptr_vector.h +++ b/src/ptr_vector.h @@ -1,7 +1,7 @@ #ifndef PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/regex.h b/src/regex.h index d797e9a..8722e62 100644 --- a/src/regex.h +++ b/src/regex.h @@ -1,7 +1,7 @@ #ifndef REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/regeximpl.h b/src/regeximpl.h index aad9708..d5c20d7 100644 --- a/src/regeximpl.h +++ b/src/regeximpl.h @@ -1,7 +1,7 @@ #ifndef REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/scanner.h b/src/scanner.h index 59857ed..bc8dcbe 100644 --- a/src/scanner.h +++ b/src/scanner.h @@ -1,7 +1,7 @@ #ifndef SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/scanscalar.h b/src/scanscalar.h index 52123e7..c198cb1 100644 --- a/src/scanscalar.h +++ b/src/scanscalar.h @@ -1,7 +1,7 @@ #ifndef SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/scantag.h b/src/scantag.h index 869d9e8..38437c0 100644 --- a/src/scantag.h +++ b/src/scantag.h @@ -1,7 +1,7 @@ #ifndef SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/setting.h b/src/setting.h index f503ad2..806ccda 100644 --- a/src/setting.h +++ b/src/setting.h @@ -1,7 +1,7 @@ #ifndef SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/singledocparser.h b/src/singledocparser.h index 86688a6..3798dcc 100644 --- a/src/singledocparser.h +++ b/src/singledocparser.h @@ -1,7 +1,7 @@ #ifndef SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/stream.h b/src/stream.h index e2fd4b5..90a401e 100644 --- a/src/stream.h +++ b/src/stream.h @@ -1,7 +1,7 @@ #ifndef STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/streamcharsource.h b/src/streamcharsource.h index 55e9294..21fae4e 100644 --- a/src/streamcharsource.h +++ b/src/streamcharsource.h @@ -1,7 +1,7 @@ #ifndef STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/stringsource.h b/src/stringsource.h index 8a45755..21be3c9 100644 --- a/src/stringsource.h +++ b/src/stringsource.h @@ -1,7 +1,7 @@ #ifndef STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/tag.h b/src/tag.h index 675b15e..5f77548 100644 --- a/src/tag.h +++ b/src/tag.h @@ -1,7 +1,7 @@ #ifndef TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/src/token.h b/src/token.h index 11e97a3..9807e25 100644 --- a/src/token.h +++ b/src/token.h @@ -1,7 +1,7 @@ #ifndef TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/test/emittertests.cpp b/test/emittertests.cpp index 329ed3b..4c5c668 100644 --- a/test/emittertests.cpp +++ b/test/emittertests.cpp @@ -759,19 +759,19 @@ namespace Test void Binary(YAML::Emitter& out, std::string& desiredOutput) { - out << YAML::Binary("Hello, World!", 13); + out << YAML::Binary(reinterpret_cast("Hello, World!"), 13); desiredOutput = "!!binary \"SGVsbG8sIFdvcmxkIQ==\""; } void LongBinary(YAML::Emitter& out, std::string& desiredOutput) { - out << YAML::Binary("Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.\n", 270); + out << YAML::Binary(reinterpret_cast("Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.\n"), 270); desiredOutput = "!!binary \"TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4K\""; } void EmptyBinary(YAML::Emitter& out, std::string& desiredOutput) { - out << YAML::Binary("", 0); + out << YAML::Binary(reinterpret_cast(""), 0); desiredOutput = "!!binary \"\""; } @@ -846,6 +846,14 @@ namespace Test out << "Oops"; desiredOutput = "Hi\n---\nBye\n---\nOops"; } + + void EmptyString(YAML::Emitter& out, std::string& desiredOutput) + { + out << YAML::BeginMap; + out << YAML::Key << "key" << YAML::Value << ""; + out << YAML::EndMap; + desiredOutput = "key: \"\""; + } //////////////////////////////////////////////////////////////////////////////////////////////////////// // incorrect emitting @@ -1058,6 +1066,7 @@ namespace Test RunEmitterTest(&Emitter::BoolFormatting, "bool formatting", passed, total); RunEmitterTest(&Emitter::DocStartAndEnd, "doc start and end", passed, total); RunEmitterTest(&Emitter::ImplicitDocStart, "implicit doc start", passed, total); + RunEmitterTest(&Emitter::EmptyString, "empty string", passed, total); RunEmitterErrorTest(&Emitter::ExtraEndSeq, "extra EndSeq", passed, total); RunEmitterErrorTest(&Emitter::ExtraEndMap, "extra EndMap", passed, total); diff --git a/test/emittertests.h b/test/emittertests.h index 4ba5f72..e7c6ac5 100644 --- a/test/emittertests.h +++ b/test/emittertests.h @@ -1,7 +1,7 @@ #ifndef EMITTERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define EMITTERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/test/parsertests.cpp b/test/parsertests.cpp index e7da3b7..f6218db 100644 --- a/test/parsertests.cpp +++ b/test/parsertests.cpp @@ -864,6 +864,22 @@ namespace Test } return true; } + + bool NonConstKey() + { + std::string input = "{a: 1}"; + std::stringstream stream(input); + YAML::Parser parser(stream); + YAML::Node doc; + parser.GetNextDocument(doc); + + std::vector key(2); + key[0] = 'a'; + key[1] = '\0'; + if(doc[&key[0]].to() != 1) + return false; + return true; + } } namespace { @@ -1142,6 +1158,7 @@ namespace Test RunParserTest(&Parser::ExplicitNonSpecificSequenceTag, "explicit, non-specific sequence tag", passed, total); RunParserTest(&Parser::Infinity, "infinity", passed, total); RunParserTest(&Parser::NaN, "NaN", passed, total); + RunParserTest(&Parser::NonConstKey, "non const key", passed, total); RunEncodingTest(&EncodeToUtf8, false, "UTF-8, no BOM", passed, total); RunEncodingTest(&EncodeToUtf8, true, "UTF-8 with BOM", passed, total); diff --git a/test/parsertests.h b/test/parsertests.h index a67fff8..f3de1b8 100644 --- a/test/parsertests.h +++ b/test/parsertests.h @@ -1,7 +1,7 @@ #ifndef PARSERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define PARSERTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/test/spectests.cpp b/test/spectests.cpp index f3f05bc..185c976 100644 --- a/test/spectests.cpp +++ b/test/spectests.cpp @@ -2032,7 +2032,7 @@ namespace Test { YAML_ASSERT(doc.size() == 3); YAML_ASSERT(doc["strip"].to() == "# text"); YAML_ASSERT(doc["clip"].to() == "# text\n"); - YAML_ASSERT(doc["keep"].to() == "# text\n"); + YAML_ASSERT(doc["keep"].to() == "# text\n"); // Note: I believe this is a bug in the YAML spec - it should be "# text\n\n" return true; } @@ -2290,7 +2290,7 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); - YAML_ASSERT(doc["literal"].to() == "value"); + YAML_ASSERT(doc["literal"].to() == "value"); // Note: I believe this is a bug in the YAML spec - it should be "value\n" YAML_ASSERT(doc["folded"].to() == "value"); YAML_ASSERT(doc["folded"].Tag() == "!foo"); return true; diff --git a/test/spectests.h b/test/spectests.h index e8acfb7..8561d08 100644 --- a/test/spectests.h +++ b/test/spectests.h @@ -1,7 +1,7 @@ #ifndef SPECTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define SPECTESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif diff --git a/test/tests.h b/test/tests.h index ec466a4..757dbc5 100644 --- a/test/tests.h +++ b/test/tests.h @@ -1,7 +1,7 @@ #ifndef TESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #define TESTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 -#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4 +#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 #pragma once #endif