From 482c0afe2fd4d3f0197c030e51e1abcad1f90e1c Mon Sep 17 00:00:00 2001 From: beder Date: Tue, 18 Oct 2011 00:16:51 -0500 Subject: [PATCH] Split the yaml.h file into new/old API, which we'll then copy to yaml.h at build time (so the right one gets installed) --- CMakeLists.txt | 12 ++++++++++++ include/yaml-cpp/null.h | 4 +--- include/yaml-cpp/parser.h | 4 +--- include/yaml-cpp/{yaml.h => yaml-new-api.h} | 10 ---------- include/yaml-cpp/yaml-old-api.h | 18 ++++++++++++++++++ 5 files changed, 32 insertions(+), 16 deletions(-) rename include/yaml-cpp/{yaml.h => yaml-new-api.h} (80%) create mode 100644 include/yaml-cpp/yaml-old-api.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 3639776..b72a67e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,10 +79,22 @@ if(YAML_CPP_BUILD_OLD_API) list(APPEND public_headers ${common_public_headers} ${old_api_public_headers}) list(APPEND private_headers ${common_private_headers} ${old_api_private_headers}) add_definitions(-DYAML_CPP_OLD_API) + + ADD_CUSTOM_COMMAND( + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/yaml-cpp/yaml.h + COMMAND ${CMAKE_COMMAND} copy ${CMAKE_CURRENT_SOURCE_DIR}/include/yaml-cpp/yaml-old-api.h ${CMAKE_CURRENT_SOURCE_DIR}/include/yaml-cpp/yaml.h + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/include/yaml-cpp/yaml-old-api.h + ) else() list(APPEND sources ${common_sources} ${new_api_sources}) list(APPEND public_headers ${common_public_headers} ${new_api_public_headers}) list(APPEND private_headers ${common_private_headers} ${new_api_private_headers}) + + ADD_CUSTOM_COMMAND( + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/yaml-cpp/yaml.h + COMMAND ${CMAKE_COMMAND} copy ${CMAKE_CURRENT_SOURCE_DIR}/include/yaml-cpp/yaml-new-api.h ${CMAKE_CURRENT_SOURCE_DIR}/include/yaml-cpp/yaml.h + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/include/yaml-cpp/yaml-new-api.h + ) endif() if(YAML_CPP_BUILD_CONTRIB) diff --git a/include/yaml-cpp/null.h b/include/yaml-cpp/null.h index 63b897b..711f18c 100644 --- a/include/yaml-cpp/null.h +++ b/include/yaml-cpp/null.h @@ -16,9 +16,7 @@ namespace YAML inline bool operator == (const _Null&, const _Null&) { return true; } inline bool operator != (const _Null&, const _Null&) { return false; } -#if YAML_CPP_OLD_API - YAML_CPP_API bool IsNull(const Node& node); -#endif + YAML_CPP_API bool IsNull(const Node& node); // old API only extern YAML_CPP_API _Null Null; } diff --git a/include/yaml-cpp/parser.h b/include/yaml-cpp/parser.h index 232f548..f71cdff 100644 --- a/include/yaml-cpp/parser.h +++ b/include/yaml-cpp/parser.h @@ -32,9 +32,7 @@ namespace YAML void Load(std::istream& in); bool HandleNextDocument(EventHandler& eventHandler); -#if YAML_CPP_OLD_API - bool GetNextDocument(Node& document); -#endif + bool GetNextDocument(Node& document); // old API only void PrintTokens(std::ostream& out); diff --git a/include/yaml-cpp/yaml.h b/include/yaml-cpp/yaml-new-api.h similarity index 80% rename from include/yaml-cpp/yaml.h rename to include/yaml-cpp/yaml-new-api.h index 860c333..0b609c6 100644 --- a/include/yaml-cpp/yaml.h +++ b/include/yaml-cpp/yaml-new-api.h @@ -11,14 +11,6 @@ #include "yaml-cpp/stlemitter.h" #include "yaml-cpp/exceptions.h" -#ifdef YAML_CPP_OLD_API - -#include "yaml-cpp/old-api/node.h" -#include "yaml-cpp/old-api/stlnode.h" -#include "yaml-cpp/old-api/iterator.h" - -#else - #include "yaml-cpp/node/node.h" #include "yaml-cpp/node/impl.h" #include "yaml-cpp/node/convert.h" @@ -27,6 +19,4 @@ #include "yaml-cpp/node/parse.h" #include "yaml-cpp/node/emit.h" -#endif // YAML_CPP_OLD_API - #endif // YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/include/yaml-cpp/yaml-old-api.h b/include/yaml-cpp/yaml-old-api.h new file mode 100644 index 0000000..8fa5854 --- /dev/null +++ b/include/yaml-cpp/yaml-old-api.h @@ -0,0 +1,18 @@ +#ifndef YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 +#define YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 + +#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/parser.h" +#include "yaml-cpp/emitter.h" +#include "yaml-cpp/stlemitter.h" +#include "yaml-cpp/exceptions.h" + +#include "yaml-cpp/old-api/node.h" +#include "yaml-cpp/old-api/stlnode.h" +#include "yaml-cpp/old-api/iterator.h" + +#endif // YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66