├── .gitignore ├── Source └── UnrealYAML │ ├── Private │ ├── Emitter.cpp │ ├── UnrealYAML.cpp │ ├── Tests │ │ ├── TestStructs.h │ │ ├── Inputs.h │ │ ├── ConvertToStruct.cpp │ │ └── Parse.cpp │ ├── Node.cpp │ ├── NodeHelpers.cpp │ └── Parsing.cpp │ ├── Public │ ├── Emitter.h │ ├── Enums.h │ └── Parsing.h │ ├── yaml-cpp │ ├── src │ │ ├── null.cpp │ │ ├── depthguard.cpp │ │ ├── yaml_node.cpp │ │ ├── directives.cpp │ │ ├── contrib │ │ │ ├── graphbuilder.cpp │ │ │ ├── graphbuilderadapter.h │ │ │ └── graphbuilderadapter.cpp │ │ ├── emit.cpp │ │ ├── memory.cpp │ │ ├── scantag.h │ │ ├── directives.h │ │ ├── tag.h │ │ ├── exceptions.cpp │ │ ├── indentation.h │ │ ├── regex_yaml.cpp │ │ ├── collectionstack.h │ │ ├── tag.cpp │ │ ├── stringsource.h │ │ ├── ptr_vector.h │ │ ├── ostream_wrapper.cpp │ │ ├── yaml_parse.cpp │ │ ├── streamcharsource.h │ │ ├── scantag.cpp │ │ ├── nodeevents.h │ │ ├── convert.cpp │ │ ├── emitterutils.h │ │ ├── token.h │ │ ├── stream.h │ │ ├── nodebuilder.h │ │ ├── singledocparser.h │ │ ├── scanscalar.h │ │ ├── regex_yaml.h │ │ ├── nodeevents.cpp │ │ ├── setting.h │ │ ├── parser.cpp │ │ ├── binary.cpp │ │ ├── emitfromevents.cpp │ │ ├── nodebuilder.cpp │ │ ├── simplekey.cpp │ │ ├── exp.cpp │ │ ├── scanner.h │ │ ├── regeximpl.h │ │ ├── exp.h │ │ └── emitterstate.h │ ├── include │ │ ├── emitterstyle.h │ │ ├── node │ │ │ ├── type.h │ │ │ ├── detail │ │ │ │ ├── iterator_fwd.h │ │ │ │ ├── memory.h │ │ │ │ ├── iterator.h │ │ │ │ ├── node_ref.h │ │ │ │ ├── node_data.h │ │ │ │ ├── node_iterator.h │ │ │ │ ├── node.h │ │ │ │ └── impl.h │ │ │ ├── ptr.h │ │ │ ├── emit.h │ │ │ ├── iterator.h │ │ │ ├── parse.h │ │ │ └── node.h │ │ ├── anchor.h │ │ ├── emitterdef.h │ │ ├── noexcept.h │ │ ├── yaml.h │ │ ├── null.h │ │ ├── mark.h │ │ ├── contrib │ │ │ ├── anchordict.h │ │ │ └── graphbuilder.h │ │ ├── stlemitter.h │ │ ├── eventhandler.h │ │ ├── emitfromevents.h │ │ ├── ostream_wrapper.h │ │ ├── binary.h │ │ ├── depthguard.h │ │ ├── parser.h │ │ ├── traits.h │ │ └── emittermanip.h │ └── LICENSE │ └── UnrealYAML.Build.cs ├── Resources └── Icon128.png ├── Patches ├── filename-conflicts.patch └── unreachable-code.patch ├── UnrealYAML.Target.cs ├── UnrealYAML.uplugin ├── LICENSE ├── README.md └── .clang-format /.gitignore: -------------------------------------------------------------------------------- 1 | Binaries/ 2 | Intermediate/ -------------------------------------------------------------------------------- /Source/UnrealYAML/Private/Emitter.cpp: -------------------------------------------------------------------------------- 1 | #include "UnrealYAML/Public/Emitter.h" 2 | -------------------------------------------------------------------------------- /Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jwindgassen/UnrealYAML/HEAD/Resources/Icon128.png -------------------------------------------------------------------------------- /Patches/filename-conflicts.patch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jwindgassen/UnrealYAML/HEAD/Patches/filename-conflicts.patch -------------------------------------------------------------------------------- /Source/UnrealYAML/Private/UnrealYAML.cpp: -------------------------------------------------------------------------------- 1 | #include "Modules/ModuleManager.h" 2 | 3 | IMPLEMENT_MODULE(FDefaultModuleImpl, UnrealYAML) 4 | -------------------------------------------------------------------------------- /Source/UnrealYAML/Public/Emitter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "yaml.h" 4 | 5 | // An Emitter used to create new YAML-Structures. You can use the "<<"-operator to add Elements to the Structure. 6 | using FYamlEmitter = YAML::Emitter; 7 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/null.cpp: -------------------------------------------------------------------------------- 1 | #include "null.h" 2 | 3 | namespace YAML { 4 | _Null Null; 5 | 6 | bool IsNullString(const std::string& str) { 7 | return str.empty() || str == "~" || str == "null" || str == "Null" || 8 | str == "NULL"; 9 | } 10 | } // namespace YAML 11 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/depthguard.cpp: -------------------------------------------------------------------------------- 1 | #include "depthguard.h" 2 | 3 | namespace YAML { 4 | 5 | DeepRecursion::DeepRecursion(int depth, const Mark& mark_, 6 | const std::string& msg_) 7 | : ParserException(mark_, msg_), m_depth(depth) {} 8 | 9 | } // namespace YAML 10 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/yaml_node.cpp: -------------------------------------------------------------------------------- 1 | #include "node/node.h" 2 | #include "nodebuilder.h" 3 | #include "nodeevents.h" 4 | 5 | namespace YAML { 6 | Node Clone(const Node& node) { 7 | NodeEvents events(node); 8 | NodeBuilder builder; 9 | events.Emit(builder); 10 | return builder.Root(); 11 | } 12 | } // namespace YAML 13 | -------------------------------------------------------------------------------- /UnrealYAML.Target.cs: -------------------------------------------------------------------------------- 1 | using UnrealBuildTool; 2 | 3 | public class UnrealYAMLTarget : TargetRules { 4 | public UnrealYAMLTarget(TargetInfo Target) : base(Target) { 5 | Type = UnrealBuildTool.TargetType.Editor; 6 | bForceEnableExceptions = true; 7 | bForceEnableObjCExceptions = true; 8 | bForceEnableRTTI = true; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/directives.cpp: -------------------------------------------------------------------------------- 1 | #include "directives.h" 2 | 3 | namespace YAML { 4 | Directives::Directives() : version{true, 1, 2}, tags{} {} 5 | 6 | const std::string Directives::TranslateTagHandle( 7 | const std::string& handle) const { 8 | auto it = tags.find(handle); 9 | if (it == tags.end()) { 10 | if (handle == "!!") 11 | return "tag:yaml.org,2002:"; 12 | return handle; 13 | } 14 | 15 | return it->second; 16 | } 17 | } // namespace YAML 18 | -------------------------------------------------------------------------------- /Source/UnrealYAML/Private/Tests/TestStructs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "TestStructs.generated.h" 4 | 5 | 6 | // SimpleYaml 7 | USTRUCT() 8 | struct FSimpleStruct { 9 | GENERATED_BODY() 10 | 11 | UPROPERTY() 12 | FString Str; 13 | 14 | UPROPERTY() 15 | int32 Int{}; 16 | 17 | UPROPERTY() 18 | bool Bool{}; 19 | 20 | UPROPERTY() 21 | TArray Arr; 22 | 23 | UPROPERTY() 24 | TMap Map; 25 | }; 26 | 27 | // Cannot test for complex yaml, as we can't represent mixed nested types :( 28 | -------------------------------------------------------------------------------- /Patches/unreachable-code.patch: -------------------------------------------------------------------------------- 1 | diff --git a/Source/UnrealYAML/yaml-cpp/src/emitterstate.h b/Source/UnrealYAML/yaml-cpp/src/emitterstate.h 2 | --- a/Source/UnrealYAML/yaml-cpp/src/emitterstate.h (revision db2517279ebb21d208e296dff95f423086fa7774) 3 | +++ b/Source/UnrealYAML/yaml-cpp/src/emitterstate.h (date 1734732999348) 4 | @@ -175,10 +175,6 @@ 5 | else 6 | return EmitterNodeType::BlockMap; 7 | } 8 | - 9 | - // can't get here 10 | - assert(false); 11 | - return EmitterNodeType::NoType; 12 | } 13 | }; 14 | 15 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/contrib/graphbuilder.cpp: -------------------------------------------------------------------------------- 1 | #include "contrib/graphbuilder.h" 2 | #include "graphbuilderadapter.h" 3 | 4 | #include "parser.h" 5 | 6 | namespace YAML { 7 | class GraphBuilderInterface; 8 | 9 | void* BuildGraphOfNextDocument(Parser& parser, 10 | GraphBuilderInterface& graphBuilder) { 11 | GraphBuilderAdapter eventHandler(graphBuilder); 12 | if (parser.HandleNextDocument(eventHandler)) { 13 | return eventHandler.RootNode(); 14 | } 15 | return nullptr; 16 | } 17 | } // namespace YAML 18 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/emitterstyle.h: -------------------------------------------------------------------------------- 1 | #ifndef EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | namespace YAML { 11 | enum class EmitterStyle { Default, Block, Flow }; 12 | } 13 | 14 | #endif // EMITTERSTYLE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 15 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/node/type.h: -------------------------------------------------------------------------------- 1 | #ifndef VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | namespace YAML { 11 | enum class NodeType {Undefined, Null, Scalar, Sequence, Map}; 12 | } 13 | 14 | #endif // VALUE_TYPE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 15 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/anchor.h: -------------------------------------------------------------------------------- 1 | #ifndef ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | namespace YAML { 13 | using anchor_t = std::size_t; 14 | const anchor_t NullAnchor = 0; 15 | } 16 | 17 | #endif // ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 18 | -------------------------------------------------------------------------------- /Source/UnrealYAML/Private/Tests/Inputs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Empty YAML 4 | const FString EmptyYaml(""); 5 | 6 | // POD YAML 7 | const FString SimpleYaml( 8 | "str: A String \n" 9 | "int: 42 \n" 10 | "bool: true \n" 11 | "arr: [1, 2, 3] \n" 12 | "map: \n" 13 | " a: 1 \n" 14 | " b: 2 \n" 15 | ); 16 | 17 | const FString ComplexYaml( 18 | "nested: [[1, 2, 3], [a, b, c, d], null] \n" 19 | "mixed: [true, 3.1415926535897932] \n" 20 | "struct: \n" 21 | " color: magenta \n" 22 | " set: [0, 0, 1, 3, 5, 5, 6] \n" 23 | ); 24 | 25 | const FString ErroneousYaml("err: -"); 26 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/emitterdef.h: -------------------------------------------------------------------------------- 1 | #ifndef EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | namespace YAML { 11 | enum class EmitterNodeType {NoType, Property, Scalar, FlowSeq, BlockSeq, FlowMap, BlockMap}; 12 | } 13 | 14 | #endif // EMITTERDEF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 15 | -------------------------------------------------------------------------------- /UnrealYAML.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "Version": 1, 4 | "VersionName": "1.0", 5 | "FriendlyName": "UnrealYAML", 6 | "Description": "An Unreal-Compatible Wrapper for the yaml-cpp Library", 7 | "Category": "Other", 8 | "CreatedBy": "Jonathan Windgassen", 9 | "CreatedByURL": "j.windgassen@fz-juelich.de", 10 | "DocsURL": "", 11 | "MarketplaceURL": "", 12 | "SupportURL": "", 13 | "CanContainContent": true, 14 | "IsBetaVersion": false, 15 | "IsExperimentalVersion": false, 16 | "Installed": false, 17 | "Modules": [ 18 | { 19 | "Name": "UnrealYAML", 20 | "Type": "Runtime", 21 | "LoadingPhase": "Default" 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/emit.cpp: -------------------------------------------------------------------------------- 1 | #include "node/emit.h" 2 | #include "nodeevents.h" 3 | #include "emitfromevents.h" 4 | #include "emitter.h" 5 | 6 | namespace YAML { 7 | Emitter& operator<<(Emitter& out, const Node& node) { 8 | EmitFromEvents emitFromEvents(out); 9 | NodeEvents events(node); 10 | events.Emit(emitFromEvents); 11 | return out; 12 | } 13 | 14 | std::ostream& operator<<(std::ostream& out, const Node& node) { 15 | Emitter emitter(out); 16 | emitter << node; 17 | return out; 18 | } 19 | 20 | std::string Dump(const Node& node) { 21 | Emitter emitter; 22 | emitter << node; 23 | return emitter.c_str(); 24 | } 25 | } // namespace YAML 26 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/noexcept.h: -------------------------------------------------------------------------------- 1 | #ifndef NOEXCEPT_H_768872DA_476C_11EA_88B8_90B11C0C0FF8 2 | #define NOEXCEPT_H_768872DA_476C_11EA_88B8_90B11C0C0FF8 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | // This is here for compatibility with older versions of Visual Studio 11 | // which don't support noexcept. 12 | #if defined(_MSC_VER) && _MSC_VER < 1900 13 | #define YAML_CPP_NOEXCEPT _NOEXCEPT 14 | #else 15 | #define YAML_CPP_NOEXCEPT noexcept 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/memory.cpp: -------------------------------------------------------------------------------- 1 | #include "node/detail/memory.h" 2 | #include "node/detail/node.h" // IWYU pragma: keep 3 | #include "node/ptr.h" 4 | 5 | namespace YAML { 6 | namespace detail { 7 | 8 | void memory_holder::merge(memory_holder& rhs) { 9 | if (m_pMemory == rhs.m_pMemory) 10 | return; 11 | 12 | m_pMemory->merge(*rhs.m_pMemory); 13 | rhs.m_pMemory = m_pMemory; 14 | } 15 | 16 | node& memory::create_node() { 17 | shared_node pNode(new node); 18 | m_nodes.insert(pNode); 19 | return *pNode; 20 | } 21 | 22 | void memory::merge(const memory& rhs) { 23 | m_nodes.insert(rhs.m_nodes.begin(), rhs.m_nodes.end()); 24 | } 25 | } // namespace detail 26 | } // namespace YAML 27 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/scantag.h: -------------------------------------------------------------------------------- 1 | #ifndef SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include "stream.h" 12 | 13 | namespace YAML { 14 | const std::string ScanVerbatimTag(Stream& INPUT); 15 | const std::string ScanTagHandle(Stream& INPUT, bool& canBeHandle); 16 | const std::string ScanTagSuffix(Stream& INPUT); 17 | } 18 | 19 | #endif // SCANTAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 20 | -------------------------------------------------------------------------------- /Source/UnrealYAML/UnrealYAML.Build.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using UnrealBuildTool; 3 | 4 | public class UnrealYAML : ModuleRules { 5 | public UnrealYAML(ReadOnlyTargetRules Target) : base(Target) { 6 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 7 | Type = ModuleType.CPlusPlus; 8 | PublicDependencyModuleNames.AddRange(new[] { "Core", "CoreUObject", "Engine" }); 9 | 10 | bEnableExceptions = true; 11 | 12 | // Replace the source ExportHeader with our ExportHeader 13 | PublicDefinitions.Add("YAML_CPP_API=UNREALYAML_API"); 14 | 15 | PublicIncludePaths.Add(Path.Combine(PluginDirectory, "Source", "UnrealYAML", "yaml-cpp", "include")); 16 | PrivateIncludePaths.Add(Path.Combine(PluginDirectory, "Source", "UnrealYAML", "yaml-cpp", "src")); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/yaml.h: -------------------------------------------------------------------------------- 1 | #ifndef YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "parser.h" 11 | #include "emitter.h" 12 | #include "emitterstyle.h" 13 | #include "stlemitter.h" 14 | #include "exceptions.h" 15 | 16 | #include "node/node.h" 17 | #include "node/impl.h" 18 | #include "node/convert.h" 19 | #include "node/iterator.h" 20 | #include "node/detail/impl.h" 21 | #include "node/parse.h" 22 | #include "node/emit.h" 23 | 24 | #endif // YAML_H_62B23520_7C8E_11DE_8A39_0800200C9A66 25 | -------------------------------------------------------------------------------- /Source/UnrealYAML/Public/Enums.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CoreMinimal.h" 4 | 5 | #include "Enums.generated.h" 6 | 7 | 8 | // Possible States a Node can be in 9 | UENUM() 10 | enum class EYamlNodeType : uint8 { 11 | // Invalid Node 12 | Undefined, 13 | 14 | // Node has no Content 15 | Empty, 16 | 17 | // Node is storing a single Value 18 | Scalar, 19 | 20 | // Node is a List 21 | Sequence, 22 | 23 | // Node is Storing Key-Value pairs 24 | Map 25 | }; 26 | 27 | 28 | // Different ways to align data in a list/map in a file 29 | UENUM() 30 | enum class EYamlEmitterStyle : uint8 { 31 | // Keep the default alignment 32 | Default, 33 | 34 | // Align the data blocking -> 1 item per line 35 | Block, 36 | 37 | // Align the data flowing -> all items on the same line 38 | Flow 39 | }; 40 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/directives.h: -------------------------------------------------------------------------------- 1 | #ifndef DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | namespace YAML { 14 | struct Version { 15 | bool isDefault; 16 | int major, minor; 17 | }; 18 | 19 | struct Directives { 20 | Directives(); 21 | 22 | const std::string TranslateTagHandle(const std::string& handle) const; 23 | 24 | Version version; 25 | std::map tags; 26 | }; 27 | } 28 | 29 | #endif // DIRECTIVES_H_62B23520_7C8E_11DE_8A39_0800200C9A66 30 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/tag.h: -------------------------------------------------------------------------------- 1 | #ifndef TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | namespace YAML { 13 | struct Directives; 14 | struct Token; 15 | 16 | struct Tag { 17 | enum TYPE { 18 | VERBATIM, 19 | PRIMARY_HANDLE, 20 | SECONDARY_HANDLE, 21 | NAMED_HANDLE, 22 | NON_SPECIFIC 23 | }; 24 | 25 | Tag(const Token& token); 26 | const std::string Translate(const Directives& directives); 27 | 28 | TYPE type; 29 | std::string handle, value; 30 | }; 31 | } 32 | 33 | #endif // TAG_H_62B23520_7C8E_11DE_8A39_0800200C9A66 34 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/null.h: -------------------------------------------------------------------------------- 1 | #ifndef NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | 11 | #include 12 | 13 | namespace YAML { 14 | class Node; 15 | 16 | struct YAML_CPP_API _Null {}; 17 | inline bool operator==(const _Null&, const _Null&) { return true; } 18 | inline bool operator!=(const _Null&, const _Null&) { return false; } 19 | 20 | YAML_CPP_API bool IsNull(const Node& node); // old API only 21 | YAML_CPP_API bool IsNullString(const std::string& str); 22 | 23 | extern YAML_CPP_API _Null Null; 24 | } 25 | 26 | #endif // NULL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 27 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/mark.h: -------------------------------------------------------------------------------- 1 | #ifndef MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | 11 | 12 | namespace YAML { 13 | struct YAML_CPP_API Mark { 14 | Mark() : pos(0), line(0), column(0) {} 15 | 16 | static const Mark null_mark() { return Mark(-1, -1, -1); } 17 | 18 | bool is_null() const { return pos == -1 && line == -1 && column == -1; } 19 | 20 | int pos; 21 | int line, column; 22 | 23 | private: 24 | Mark(int pos_, int line_, int column_) 25 | : pos(pos_), line(line_), column(column_) {} 26 | }; 27 | } 28 | 29 | #endif // MARK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 30 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/node/detail/iterator_fwd.h: -------------------------------------------------------------------------------- 1 | #ifndef VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace YAML { 16 | 17 | namespace detail { 18 | struct iterator_value; 19 | template 20 | class iterator_base; 21 | } 22 | 23 | using iterator = detail::iterator_base; 24 | using const_iterator = detail::iterator_base; 25 | } 26 | 27 | #endif // VALUE_DETAIL_ITERATOR_FWD_H_62B23520_7C8E_11DE_8A39_0800200C9A66 28 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/node/ptr.h: -------------------------------------------------------------------------------- 1 | #ifndef VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | 11 | #include 12 | 13 | namespace YAML { 14 | namespace detail { 15 | class node; 16 | class node_ref; 17 | class node_data; 18 | class memory; 19 | class memory_holder; 20 | 21 | using shared_node = std::shared_ptr; 22 | using shared_node_ref = std::shared_ptr; 23 | using shared_node_data = std::shared_ptr; 24 | using shared_memory_holder = std::shared_ptr; 25 | using shared_memory = std::shared_ptr; 26 | } 27 | } 28 | 29 | #endif // VALUE_PTR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 30 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/exceptions.cpp: -------------------------------------------------------------------------------- 1 | #include "exceptions.h" 2 | #include "noexcept.h" 3 | 4 | namespace YAML { 5 | 6 | // These destructors are defined out-of-line so the vtable is only emitted once. 7 | Exception::~Exception() YAML_CPP_NOEXCEPT = default; 8 | ParserException::~ParserException() YAML_CPP_NOEXCEPT = default; 9 | RepresentationException::~RepresentationException() YAML_CPP_NOEXCEPT = default; 10 | InvalidScalar::~InvalidScalar() YAML_CPP_NOEXCEPT = default; 11 | KeyNotFound::~KeyNotFound() YAML_CPP_NOEXCEPT = default; 12 | InvalidNode::~InvalidNode() YAML_CPP_NOEXCEPT = default; 13 | BadConversion::~BadConversion() YAML_CPP_NOEXCEPT = default; 14 | BadDereference::~BadDereference() YAML_CPP_NOEXCEPT = default; 15 | BadSubscript::~BadSubscript() YAML_CPP_NOEXCEPT = default; 16 | BadPushback::~BadPushback() YAML_CPP_NOEXCEPT = default; 17 | BadInsert::~BadInsert() YAML_CPP_NOEXCEPT = default; 18 | EmitterException::~EmitterException() YAML_CPP_NOEXCEPT = default; 19 | BadFile::~BadFile() YAML_CPP_NOEXCEPT = default; 20 | } // namespace YAML 21 | -------------------------------------------------------------------------------- /Source/UnrealYAML/Private/Tests/ConvertToStruct.cpp: -------------------------------------------------------------------------------- 1 | #include "Misc/AutomationTest.h" 2 | #include "Parsing.h" 3 | #include "Inputs.h" 4 | #include "TestStructs.h" 5 | 6 | #if WITH_DEV_AUTOMATION_TESTS 7 | 8 | #if ENGINE_MAJOR_VERSION >= 5 9 | IMPLEMENT_SIMPLE_AUTOMATION_TEST(ConvertToStruct, "UnrealYAML.ConvertToStruct", 10 | EAutomationTestFlags_ApplicationContextMask | EAutomationTestFlags::SmokeFilter) 11 | #else 12 | IMPLEMENT_SIMPLE_AUTOMATION_TEST(ConvertToStruct, "UnrealYAML.ConvertToStruct", 13 | EAutomationTestFlags::ApplicationContextMask | EAutomationTestFlags::SmokeFilter) 14 | #endif 15 | 16 | bool ConvertToStruct::RunTest(const FString& Parameters) { 17 | // Simple Yaml 18 | { 19 | FYamlNode Node; 20 | UYamlParsing::ParseYaml(SimpleYaml, Node); 21 | 22 | FSimpleStruct SimpleStruct; 23 | TestTrue("Parse Node into SimpleStruct", ParseNodeIntoStruct(Node, SimpleStruct)); 24 | } 25 | 26 | return !HasAnyErrors(); 27 | } 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/node/emit.h: -------------------------------------------------------------------------------- 1 | #ifndef NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | namespace YAML { 16 | class Emitter; 17 | class Node; 18 | 19 | /** 20 | * Emits the node to the given {@link Emitter}. If there is an error in writing, 21 | * {@link Emitter#good} will return false. 22 | */ 23 | YAML_CPP_API Emitter& operator<<(Emitter& out, const Node& node); 24 | 25 | /** Emits the node to the given output stream. */ 26 | YAML_CPP_API std::ostream& operator<<(std::ostream& out, const Node& node); 27 | 28 | /** Converts the node to a YAML string. */ 29 | YAML_CPP_API std::string Dump(const Node& node); 30 | } // namespace YAML 31 | 32 | #endif // NODE_EMIT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 33 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2015 Jesse Beder. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 by Forschungszentrum Juelich GmbH, Juelich Supercomputing Centre 4 | Jonathan Windgassen 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/indentation.h: -------------------------------------------------------------------------------- 1 | #ifndef INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | #include "ostream_wrapper.h" 14 | 15 | namespace YAML { 16 | struct Indentation { 17 | Indentation(std::size_t n_) : n(n_) {} 18 | std::size_t n; 19 | }; 20 | 21 | inline ostream_wrapper& operator<<(ostream_wrapper& out, 22 | const Indentation& indent) { 23 | for (std::size_t i = 0; i < indent.n; i++) 24 | out << ' '; 25 | return out; 26 | } 27 | 28 | struct IndentTo { 29 | IndentTo(std::size_t n_) : n(n_) {} 30 | std::size_t n; 31 | }; 32 | 33 | inline ostream_wrapper& operator<<(ostream_wrapper& out, 34 | const IndentTo& indent) { 35 | while (out.col() < indent.n) 36 | out << ' '; 37 | return out; 38 | } 39 | } 40 | 41 | #endif // INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66 42 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/contrib/anchordict.h: -------------------------------------------------------------------------------- 1 | #ifndef ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | #include "../anchor.h" 13 | 14 | namespace YAML { 15 | /** 16 | * An object that stores and retrieves values correlating to {@link anchor_t} 17 | * values. 18 | * 19 | *

Efficient implementation that can make assumptions about how 20 | * {@code anchor_t} values are assigned by the {@link Parser} class. 21 | */ 22 | template 23 | class AnchorDict { 24 | public: 25 | AnchorDict() : m_data{} {} 26 | void Register(anchor_t anchor, T value) { 27 | if (anchor > m_data.size()) { 28 | m_data.resize(anchor); 29 | } 30 | m_data[anchor - 1] = value; 31 | } 32 | 33 | T Get(anchor_t anchor) const { return m_data[anchor - 1]; } 34 | 35 | private: 36 | std::vector m_data; 37 | }; 38 | } // namespace YAML 39 | 40 | #endif // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 41 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/regex_yaml.cpp: -------------------------------------------------------------------------------- 1 | #include "regex_yaml.h" 2 | 3 | namespace YAML { 4 | // constructors 5 | 6 | RegEx::RegEx(REGEX_OP op) : m_op(op), m_a(0), m_z(0), m_params{} {} 7 | RegEx::RegEx() : RegEx(REGEX_EMPTY) {} 8 | 9 | RegEx::RegEx(char ch) : m_op(REGEX_MATCH), m_a(ch), m_z(0), m_params{} {} 10 | 11 | RegEx::RegEx(char a, char z) : m_op(REGEX_RANGE), m_a(a), m_z(z), m_params{} {} 12 | 13 | RegEx::RegEx(const std::string& str, REGEX_OP op) 14 | : m_op(op), m_a(0), m_z(0), m_params(str.begin(), str.end()) {} 15 | 16 | // combination constructors 17 | RegEx operator!(const RegEx& ex) { 18 | RegEx ret(REGEX_NOT); 19 | ret.m_params.push_back(ex); 20 | return ret; 21 | } 22 | 23 | RegEx operator|(const RegEx& ex1, const RegEx& ex2) { 24 | RegEx ret(REGEX_OR); 25 | ret.m_params.push_back(ex1); 26 | ret.m_params.push_back(ex2); 27 | return ret; 28 | } 29 | 30 | RegEx operator&(const RegEx& ex1, const RegEx& ex2) { 31 | RegEx ret(REGEX_AND); 32 | ret.m_params.push_back(ex1); 33 | ret.m_params.push_back(ex2); 34 | return ret; 35 | } 36 | 37 | RegEx operator+(const RegEx& ex1, const RegEx& ex2) { 38 | RegEx ret(REGEX_SEQ); 39 | ret.m_params.push_back(ex1); 40 | ret.m_params.push_back(ex2); 41 | return ret; 42 | } 43 | } // namespace YAML 44 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/node/detail/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | 13 | #include "node/ptr.h" 14 | 15 | namespace YAML { 16 | namespace detail { 17 | class node; 18 | } // namespace detail 19 | } // namespace YAML 20 | 21 | namespace YAML { 22 | namespace detail { 23 | class YAML_CPP_API memory { 24 | public: 25 | memory() : m_nodes{} {} 26 | node& create_node(); 27 | void merge(const memory& rhs); 28 | 29 | private: 30 | using Nodes = std::set; 31 | Nodes m_nodes; 32 | }; 33 | 34 | class YAML_CPP_API memory_holder { 35 | public: 36 | memory_holder() : m_pMemory(new memory) {} 37 | 38 | node& create_node() { return m_pMemory->create_node(); } 39 | void merge(memory_holder& rhs); 40 | 41 | private: 42 | shared_memory m_pMemory; 43 | }; 44 | } // namespace detail 45 | } // namespace YAML 46 | 47 | #endif // VALUE_DETAIL_MEMORY_H_62B23520_7C8E_11DE_8A39_0800200C9A66 48 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/collectionstack.h: -------------------------------------------------------------------------------- 1 | #ifndef COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | namespace YAML { 14 | enum class CollectionType {NoCollection, BlockMap, BlockSeq, FlowMap, FlowSeq, CompactMap }; 15 | 16 | class CollectionStack { 17 | public: 18 | CollectionStack() : collectionStack{} {} 19 | CollectionType GetCurCollectionType() const { 20 | if (collectionStack.empty()) 21 | return CollectionType::NoCollection; 22 | return collectionStack.top(); 23 | } 24 | 25 | void PushCollectionType(CollectionType type) { 26 | collectionStack.push(type); 27 | } 28 | void PopCollectionType(CollectionType type) { 29 | assert(type == GetCurCollectionType()); 30 | (void)type; 31 | collectionStack.pop(); 32 | } 33 | 34 | private: 35 | std::stack collectionStack; 36 | }; 37 | } // namespace YAML 38 | 39 | #endif // COLLECTIONSTACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66 40 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/node/iterator.h: -------------------------------------------------------------------------------- 1 | #ifndef VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | 11 | #include "node/node.h" 12 | #include "node/detail/iterator_fwd.h" 13 | #include "node/detail/iterator.h" 14 | #include 15 | #include 16 | #include 17 | 18 | // Assert in place so gcc + libc++ combination properly builds 19 | static_assert(std::is_constructible::value, "Node must be copy constructable"); 20 | 21 | namespace YAML { 22 | namespace detail { 23 | struct iterator_value : public Node, std::pair { 24 | iterator_value() = default; 25 | explicit iterator_value(const Node& rhs) 26 | : Node(rhs), 27 | std::pair(Node(Node::ZombieNode), Node(Node::ZombieNode)) {} 28 | explicit iterator_value(const Node& key, const Node& value) 29 | : Node(Node::ZombieNode), std::pair(key, value) {} 30 | }; 31 | } 32 | } 33 | 34 | #endif // VALUE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 35 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/tag.cpp: -------------------------------------------------------------------------------- 1 | #include "tag.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "directives.h" 7 | #include "token.h" 8 | 9 | namespace YAML { 10 | Tag::Tag(const Token& token) 11 | : type(static_cast(token.data)), handle{}, value{} { 12 | switch (type) { 13 | case VERBATIM: 14 | value = token.value; 15 | break; 16 | case PRIMARY_HANDLE: 17 | value = token.value; 18 | break; 19 | case SECONDARY_HANDLE: 20 | value = token.value; 21 | break; 22 | case NAMED_HANDLE: 23 | handle = token.value; 24 | value = token.params[0]; 25 | break; 26 | case NON_SPECIFIC: 27 | break; 28 | default: 29 | assert(false); 30 | } 31 | } 32 | 33 | const std::string Tag::Translate(const Directives& directives) { 34 | switch (type) { 35 | case VERBATIM: 36 | return value; 37 | case PRIMARY_HANDLE: 38 | return directives.TranslateTagHandle("!") + value; 39 | case SECONDARY_HANDLE: 40 | return directives.TranslateTagHandle("!!") + value; 41 | case NAMED_HANDLE: 42 | return directives.TranslateTagHandle("!" + handle + "!") + value; 43 | case NON_SPECIFIC: 44 | // TODO: 45 | return "!"; 46 | default: 47 | assert(false); 48 | } 49 | throw std::runtime_error("yaml-cpp: internal error, bad tag type"); 50 | } 51 | } // namespace YAML 52 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/stringsource.h: -------------------------------------------------------------------------------- 1 | #ifndef STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | namespace YAML { 13 | class StringCharSource { 14 | public: 15 | StringCharSource(const char* str, std::size_t size) 16 | : m_str(str), m_size(size), m_offset(0) {} 17 | 18 | operator bool() const { return m_offset < m_size; } 19 | char operator[](std::size_t i) const { return m_str[m_offset + i]; } 20 | bool operator!() const { return !static_cast(*this); } 21 | 22 | const StringCharSource operator+(int i) const { 23 | StringCharSource source(*this); 24 | if (static_cast(source.m_offset) + i >= 0) 25 | source.m_offset += i; 26 | else 27 | source.m_offset = 0; 28 | return source; 29 | } 30 | 31 | StringCharSource& operator++() { 32 | ++m_offset; 33 | return *this; 34 | } 35 | 36 | StringCharSource& operator+=(std::size_t offset) { 37 | m_offset += offset; 38 | return *this; 39 | } 40 | 41 | private: 42 | const char* m_str; 43 | std::size_t m_size; 44 | std::size_t m_offset; 45 | }; 46 | } 47 | 48 | #endif // STRINGSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 49 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/ptr_vector.h: -------------------------------------------------------------------------------- 1 | #ifndef PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace YAML { 16 | 17 | // TODO: This class is no longer needed 18 | template 19 | class ptr_vector { 20 | public: 21 | ptr_vector() : m_data{} {} 22 | ptr_vector(const ptr_vector&) = delete; 23 | ptr_vector(ptr_vector&&) = default; 24 | ptr_vector& operator=(const ptr_vector&) = delete; 25 | ptr_vector& operator=(ptr_vector&&) = default; 26 | 27 | void clear() { m_data.clear(); } 28 | 29 | std::size_t size() const { return m_data.size(); } 30 | bool empty() const { return m_data.empty(); } 31 | 32 | void push_back(std::unique_ptr&& t) { m_data.push_back(std::move(t)); } 33 | T& operator[](std::size_t i) { return *m_data[i]; } 34 | const T& operator[](std::size_t i) const { return *m_data[i]; } 35 | 36 | T& back() { return *(m_data.back().get()); } 37 | 38 | const T& back() const { return *(m_data.back().get()); } 39 | 40 | private: 41 | std::vector> m_data; 42 | }; 43 | } // namespace YAML 44 | 45 | #endif // PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 46 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/ostream_wrapper.cpp: -------------------------------------------------------------------------------- 1 | #include "ostream_wrapper.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace YAML { 8 | ostream_wrapper::ostream_wrapper() 9 | : m_buffer(1, '\0'), 10 | m_pStream(nullptr), 11 | m_pos(0), 12 | m_row(0), 13 | m_col(0), 14 | m_comment(false) {} 15 | 16 | ostream_wrapper::ostream_wrapper(std::ostream& stream) 17 | : m_buffer{}, 18 | m_pStream(&stream), 19 | m_pos(0), 20 | m_row(0), 21 | m_col(0), 22 | m_comment(false) {} 23 | 24 | ostream_wrapper::~ostream_wrapper() = default; 25 | 26 | void ostream_wrapper::write(const std::string& str) { 27 | if (m_pStream) { 28 | m_pStream->write(str.c_str(), str.size()); 29 | } else { 30 | m_buffer.resize(std::max(m_buffer.size(), m_pos + str.size() + 1)); 31 | std::copy(str.begin(), str.end(), m_buffer.begin() + m_pos); 32 | } 33 | 34 | for (char ch : str) { 35 | update_pos(ch); 36 | } 37 | } 38 | 39 | void ostream_wrapper::write(const char* str, std::size_t size) { 40 | if (m_pStream) { 41 | m_pStream->write(str, size); 42 | } else { 43 | m_buffer.resize(std::max(m_buffer.size(), m_pos + size + 1)); 44 | std::copy(str, str + size, m_buffer.begin() + m_pos); 45 | } 46 | 47 | for (std::size_t i = 0; i < size; i++) { 48 | update_pos(str[i]); 49 | } 50 | } 51 | 52 | void ostream_wrapper::update_pos(char ch) { 53 | m_pos++; 54 | m_col++; 55 | 56 | if (ch == '\n') { 57 | m_row++; 58 | m_col = 0; 59 | m_comment = false; 60 | } 61 | } 62 | } // namespace YAML 63 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/stlemitter.h: -------------------------------------------------------------------------------- 1 | #ifndef STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace YAML { 16 | template 17 | inline Emitter& EmitSeq(Emitter& emitter, const Seq& seq) { 18 | emitter << EmitterManip::BeginSeq; 19 | for (const auto& v : seq) 20 | emitter << v; 21 | emitter << EmitterManip::EndSeq; 22 | return emitter; 23 | } 24 | 25 | template 26 | inline Emitter& operator<<(Emitter& emitter, const std::vector& v) { 27 | return EmitSeq(emitter, v); 28 | } 29 | 30 | template 31 | inline Emitter& operator<<(Emitter& emitter, const std::list& v) { 32 | return EmitSeq(emitter, v); 33 | } 34 | 35 | template 36 | inline Emitter& operator<<(Emitter& emitter, const std::set& v) { 37 | return EmitSeq(emitter, v); 38 | } 39 | 40 | template 41 | inline Emitter& operator<<(Emitter& emitter, const std::map& m) { 42 | emitter << EmitterManip::BeginMap; 43 | for (const auto& v : m) 44 | emitter << EmitterManip::Key << v.first << EmitterManip::Value << v.second; 45 | emitter << EmitterManip::EndMap; 46 | return emitter; 47 | } 48 | } 49 | 50 | #endif // STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 51 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/eventhandler.h: -------------------------------------------------------------------------------- 1 | #ifndef EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | #include "anchor.h" 13 | #include "emitterstyle.h" 14 | 15 | namespace YAML { 16 | struct Mark; 17 | 18 | class EventHandler { 19 | public: 20 | virtual ~EventHandler() = default; 21 | 22 | virtual void OnDocumentStart(const Mark& mark) = 0; 23 | virtual void OnDocumentEnd() = 0; 24 | 25 | virtual void OnNull(const Mark& mark, anchor_t anchor) = 0; 26 | virtual void OnAlias(const Mark& mark, anchor_t anchor) = 0; 27 | virtual void OnScalar(const Mark& mark, const std::string& tag, 28 | anchor_t anchor, const std::string& value) = 0; 29 | 30 | virtual void OnSequenceStart(const Mark& mark, const std::string& tag, 31 | anchor_t anchor, EmitterStyle style) = 0; 32 | virtual void OnSequenceEnd() = 0; 33 | 34 | virtual void OnMapStart(const Mark& mark, const std::string& tag, 35 | anchor_t anchor, EmitterStyle style) = 0; 36 | virtual void OnMapEnd() = 0; 37 | 38 | virtual void OnAnchor(const Mark& /*mark*/, 39 | const std::string& /*anchor_name*/) { 40 | // empty default implementation for compatibility 41 | } 42 | }; 43 | } // namespace YAML 44 | 45 | #endif // EVENTHANDLER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 46 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/yaml_parse.cpp: -------------------------------------------------------------------------------- 1 | #include "node/parse.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "nodebuilder.h" 7 | #include "node/impl.h" 8 | #include "node/node.h" 9 | #include "parser.h" 10 | 11 | namespace YAML { 12 | Node Load(const std::string& input) { 13 | std::stringstream stream(input); 14 | return Load(stream); 15 | } 16 | 17 | Node Load(const char* input) { 18 | std::stringstream stream(input); 19 | return Load(stream); 20 | } 21 | 22 | Node Load(std::istream& input) { 23 | Parser parser(input); 24 | NodeBuilder builder; 25 | if (!parser.HandleNextDocument(builder)) { 26 | return Node(); 27 | } 28 | 29 | return builder.Root(); 30 | } 31 | 32 | Node LoadFile(const std::string& filename) { 33 | std::ifstream fin(filename); 34 | if (!fin) { 35 | throw BadFile(filename); 36 | } 37 | return Load(fin); 38 | } 39 | 40 | std::vector LoadAll(const std::string& input) { 41 | std::stringstream stream(input); 42 | return LoadAll(stream); 43 | } 44 | 45 | std::vector LoadAll(const char* input) { 46 | std::stringstream stream(input); 47 | return LoadAll(stream); 48 | } 49 | 50 | std::vector LoadAll(std::istream& input) { 51 | std::vector docs; 52 | 53 | Parser parser(input); 54 | while (true) { 55 | NodeBuilder builder; 56 | if (!parser.HandleNextDocument(builder)) { 57 | break; 58 | } 59 | docs.push_back(builder.Root()); 60 | } 61 | 62 | return docs; 63 | } 64 | 65 | std::vector LoadAllFromFile(const std::string& filename) { 66 | std::ifstream fin(filename); 67 | if (!fin) { 68 | throw BadFile(filename); 69 | } 70 | return LoadAll(fin); 71 | } 72 | } // namespace YAML 73 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/streamcharsource.h: -------------------------------------------------------------------------------- 1 | #ifndef STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "noexcept.h" 11 | #include "stream.h" 12 | #include 13 | 14 | namespace YAML { 15 | 16 | class StreamCharSource { 17 | public: 18 | StreamCharSource(const Stream& stream) : m_offset(0), m_stream(stream) {} 19 | StreamCharSource(const StreamCharSource& source) = default; 20 | StreamCharSource(StreamCharSource&&) YAML_CPP_NOEXCEPT = default; 21 | StreamCharSource& operator=(const StreamCharSource&) = delete; 22 | StreamCharSource& operator=(StreamCharSource&&) = delete; 23 | ~StreamCharSource() = default; 24 | 25 | operator bool() const; 26 | char operator[](std::size_t i) const { return m_stream.CharAt(m_offset + i); } 27 | bool operator!() const { return !static_cast(*this); } 28 | 29 | const StreamCharSource operator+(int i) const; 30 | 31 | private: 32 | std::size_t m_offset; 33 | const Stream& m_stream; 34 | }; 35 | 36 | inline StreamCharSource::operator bool() const { 37 | return m_stream.ReadAheadTo(m_offset); 38 | } 39 | 40 | inline const StreamCharSource StreamCharSource::operator+(int i) const { 41 | StreamCharSource source(*this); 42 | if (static_cast(source.m_offset) + i >= 0) 43 | source.m_offset += static_cast(i); 44 | else 45 | source.m_offset = 0; 46 | return source; 47 | } 48 | } // namespace YAML 49 | 50 | #endif // STREAMCHARSOURCE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UnrealYAML: A Unreal-Compatible Wrapper for the yaml-cpp Library 2 | 3 | Welcome to the UnrealYAML Plugin, a Plugin that allows the parsing and emitting of YAML files, based on the [yaml-cpp Library](https://github.com/jbeder/yaml-cpp) 4 | 5 | **Current yaml-cpp base commit:** [328d2d8](https://github.com/jbeder/yaml-cpp/commit/328d2d85e833be7cb5a0ab246cc3f5d7e16fc67a) 6 | 7 | **Important Node:** The Plugin is far from finished and needs more testing, bug fixing and features to become fully usable and to work natively in Unreal! Feel free to contribute 8 | 9 | ## Features 10 | - Basic Functionality 11 | - Assigment 12 | - Convers Conversion to and from most frequently used Unreal Types 13 | - Iterators 14 | - Loading and Saving Files 15 | - Usable in Blueprint and C++ 16 | - Automatic Parsing to Unreal Struct using the Unreal Reflection System. 17 | 18 | ### TODO 19 | - Node into Struct Parsing: 20 | - With Blueprint Structs (if possible) 21 | - Option to respect case on key values (currently always case insensitive) 22 | - Add Map Parsing 23 | - Parse Struct into Node (Reverse Direction) 24 | - Sequences and Maps into TArray\ and TMap\ for Iteration in Blueprints 25 | - Interfacing with Unreal JSON Plugin? 26 | - Wrapper class for the Emitter? 27 | - Schema Verification? 28 | 29 | 30 | ## Tutorial 31 | You can find some examples in the [corresponding wiki page](https://github.com/jwindgassen/UnrealYAML/wiki/Examples). 32 | Since this is a thin wrapper around the *yaml-cpp* library, many of the things in their [wiki](https://github.com/jbeder/yaml-cpp/wiki/Tutorial) can also be applied to this Plugin too. 33 | 34 | 35 | ## Patches 36 | I used some patches ontop of the *yaml-cpp* library to ease the integration: 37 | - **enum-class**: Changed enums to enum classes to remove *-Wshadow* error 38 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/emitfromevents.h: -------------------------------------------------------------------------------- 1 | #ifndef EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | #include "anchor.h" 13 | #include "emitterstyle.h" 14 | #include "eventhandler.h" 15 | 16 | namespace YAML { 17 | struct Mark; 18 | } // namespace YAML 19 | 20 | namespace YAML { 21 | class Emitter; 22 | 23 | class EmitFromEvents : public EventHandler { 24 | public: 25 | EmitFromEvents(Emitter& emitter); 26 | 27 | void OnDocumentStart(const Mark& mark) override; 28 | void OnDocumentEnd() override; 29 | 30 | void OnNull(const Mark& mark, anchor_t anchor) override; 31 | void OnAlias(const Mark& mark, anchor_t anchor) override; 32 | void OnScalar(const Mark& mark, const std::string& tag, 33 | anchor_t anchor, const std::string& value) override; 34 | 35 | void OnSequenceStart(const Mark& mark, const std::string& tag, 36 | anchor_t anchor, EmitterStyle style) override; 37 | void OnSequenceEnd() override; 38 | 39 | void OnMapStart(const Mark& mark, const std::string& tag, 40 | anchor_t anchor, EmitterStyle style) override; 41 | void OnMapEnd() override; 42 | 43 | private: 44 | void BeginNode(); 45 | void EmitProps(const std::string& tag, anchor_t anchor); 46 | 47 | private: 48 | Emitter& m_emitter; 49 | 50 | enum class State {WaitingForSequenceEntry, WaitingForKey, WaitingForValue}; 51 | std::stack m_stateStack; 52 | }; 53 | } 54 | 55 | #endif // EMITFROMEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 56 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/scantag.cpp: -------------------------------------------------------------------------------- 1 | #include "scantag.h" 2 | 3 | #include "exp.h" 4 | #include "regex_yaml.h" 5 | #include "regeximpl.h" 6 | #include "stream.h" 7 | #include "exceptions.h" 8 | #include "mark.h" 9 | 10 | namespace YAML { 11 | const std::string ScanVerbatimTag(Stream& INPUT) { 12 | std::string tag; 13 | 14 | // eat the start character 15 | INPUT.get(); 16 | 17 | while (INPUT) { 18 | if (INPUT.peek() == Keys::VerbatimTagEnd) { 19 | // eat the end character 20 | INPUT.get(); 21 | return tag; 22 | } 23 | 24 | int n = Exp::URI().Match(INPUT); 25 | if (n <= 0) 26 | break; 27 | 28 | tag += INPUT.get(n); 29 | } 30 | 31 | throw ParserException(INPUT.mark(), ErrorMsg::END_OF_VERBATIM_TAG); 32 | } 33 | 34 | const std::string ScanTagHandle(Stream& INPUT, bool& canBeHandle) { 35 | std::string tag; 36 | canBeHandle = true; 37 | Mark firstNonWordChar; 38 | 39 | while (INPUT) { 40 | if (INPUT.peek() == Keys::Tag) { 41 | if (!canBeHandle) 42 | throw ParserException(firstNonWordChar, ErrorMsg::CHAR_IN_TAG_HANDLE); 43 | break; 44 | } 45 | 46 | int n = 0; 47 | if (canBeHandle) { 48 | n = Exp::Word().Match(INPUT); 49 | if (n <= 0) { 50 | canBeHandle = false; 51 | firstNonWordChar = INPUT.mark(); 52 | } 53 | } 54 | 55 | if (!canBeHandle) 56 | n = Exp::Tag().Match(INPUT); 57 | 58 | if (n <= 0) 59 | break; 60 | 61 | tag += INPUT.get(n); 62 | } 63 | 64 | return tag; 65 | } 66 | 67 | const std::string ScanTagSuffix(Stream& INPUT) { 68 | std::string tag; 69 | 70 | while (INPUT) { 71 | int n = Exp::Tag().Match(INPUT); 72 | if (n <= 0) 73 | break; 74 | 75 | tag += INPUT.get(n); 76 | } 77 | 78 | if (tag.empty()) 79 | throw ParserException(INPUT.mark(), ErrorMsg::TAG_WITH_NO_SUFFIX); 80 | 81 | return tag; 82 | } 83 | } // namespace YAML 84 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/nodeevents.h: -------------------------------------------------------------------------------- 1 | #ifndef NODE_NODEEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define NODE_NODEEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | #include "anchor.h" 14 | #include "node/ptr.h" 15 | 16 | namespace YAML { 17 | namespace detail { 18 | class node; 19 | } // namespace detail 20 | } // namespace YAML 21 | 22 | namespace YAML { 23 | class EventHandler; 24 | class Node; 25 | 26 | class NodeEvents { 27 | public: 28 | explicit NodeEvents(const Node& node); 29 | NodeEvents(const NodeEvents&) = delete; 30 | NodeEvents(NodeEvents&&) = delete; 31 | NodeEvents& operator=(const NodeEvents&) = delete; 32 | NodeEvents& operator=(NodeEvents&&) = delete; 33 | 34 | void Emit(EventHandler& handler); 35 | 36 | private: 37 | class AliasManager { 38 | public: 39 | AliasManager() : m_anchorByIdentity{}, m_curAnchor(0) {} 40 | 41 | void RegisterReference(const detail::node& node); 42 | anchor_t LookupAnchor(const detail::node& node) const; 43 | 44 | private: 45 | anchor_t _CreateNewAnchor() { return ++m_curAnchor; } 46 | 47 | private: 48 | using AnchorByIdentity = std::map; 49 | AnchorByIdentity m_anchorByIdentity; 50 | 51 | anchor_t m_curAnchor; 52 | }; 53 | 54 | void Setup(const detail::node& node); 55 | void Emit(const detail::node& node, EventHandler& handler, 56 | AliasManager& am) const; 57 | bool IsAliased(const detail::node& node) const; 58 | 59 | private: 60 | detail::shared_memory_holder m_pMemory; 61 | detail::node* m_root; 62 | 63 | using RefCount = std::map; 64 | RefCount m_refCount; 65 | }; 66 | } // namespace YAML 67 | 68 | #endif // NODE_NODEEVENTS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 69 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/convert.cpp: -------------------------------------------------------------------------------- 1 | #include "node/convert.h" 2 | 3 | #include 4 | 5 | namespace { 6 | // we're not gonna mess with the mess that is all the isupper/etc. functions 7 | bool IsLower(char ch) { return 'a' <= ch && ch <= 'z'; } 8 | bool IsUpper(char ch) { return 'A' <= ch && ch <= 'Z'; } 9 | char ToLower(char ch) { return IsUpper(ch) ? ch + 'a' - 'A' : ch; } 10 | 11 | std::string tolower(const std::string& str) { 12 | std::string s(str); 13 | std::transform(s.begin(), s.end(), s.begin(), ToLower); 14 | return s; 15 | } 16 | 17 | template 18 | bool IsEntirely(const std::string& str, T func) { 19 | return std::all_of(str.begin(), str.end(), [=](char ch) { return func(ch); }); 20 | } 21 | 22 | // IsFlexibleCase 23 | // . Returns true if 'str' is: 24 | // . UPPERCASE 25 | // . lowercase 26 | // . Capitalized 27 | bool IsFlexibleCase(const std::string& str) { 28 | if (str.empty()) 29 | return true; 30 | 31 | if (IsEntirely(str, IsLower)) 32 | return true; 33 | 34 | bool firstcaps = IsUpper(str[0]); 35 | std::string rest = str.substr(1); 36 | return firstcaps && (IsEntirely(rest, IsLower) || IsEntirely(rest, IsUpper)); 37 | } 38 | } // namespace 39 | 40 | namespace YAML { 41 | bool convert::decode(const Node& node, bool& rhs) { 42 | if (!node.IsScalar()) 43 | return false; 44 | 45 | // we can't use iostream bool extraction operators as they don't 46 | // recognize all possible values in the table below (taken from 47 | // http://yaml.org/type/bool.html) 48 | static const struct { 49 | std::string truename, falsename; 50 | } names[] = { 51 | {"y", "n"}, 52 | {"yes", "no"}, 53 | {"true", "false"}, 54 | {"on", "off"}, 55 | }; 56 | 57 | if (!IsFlexibleCase(node.Scalar())) 58 | return false; 59 | 60 | for (const auto& name : names) { 61 | if (name.truename == tolower(node.Scalar())) { 62 | rhs = true; 63 | return true; 64 | } 65 | 66 | if (name.falsename == tolower(node.Scalar())) { 67 | rhs = false; 68 | return true; 69 | } 70 | } 71 | 72 | return false; 73 | } 74 | } // namespace YAML 75 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/emitterutils.h: -------------------------------------------------------------------------------- 1 | #ifndef EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | #include "emitterstate.h" 13 | #include "emittermanip.h" 14 | #include "ostream_wrapper.h" 15 | 16 | namespace YAML { 17 | class ostream_wrapper; 18 | } // namespace YAML 19 | 20 | namespace YAML { 21 | class Binary; 22 | 23 | enum class StringFormat {Plain, SingleQuoted, DoubleQuoted, Literal}; 24 | 25 | enum class StringEscaping {None, NonAscii, JSON}; 26 | 27 | namespace Utils { 28 | StringFormat ComputeStringFormat(const std::string& str, 29 | EmitterManip strFormat, 30 | FlowType flowType, 31 | bool escapeNonAscii); 32 | 33 | bool WriteSingleQuotedString(ostream_wrapper& out, const std::string& str); 34 | bool WriteDoubleQuotedString(ostream_wrapper& out, const std::string& str, 35 | StringEscaping stringEscaping); 36 | bool WriteLiteralString(ostream_wrapper& out, const std::string& str, 37 | std::size_t indent); 38 | bool WriteChar(ostream_wrapper& out, char ch, 39 | StringEscaping stringEscapingStyle); 40 | bool WriteComment(ostream_wrapper& out, const std::string& str, 41 | std::size_t postCommentIndent); 42 | bool WriteAlias(ostream_wrapper& out, const std::string& str); 43 | bool WriteAnchor(ostream_wrapper& out, const std::string& str); 44 | bool WriteTag(ostream_wrapper& out, const std::string& str, bool verbatim); 45 | bool WriteTagWithPrefix(ostream_wrapper& out, const std::string& prefix, 46 | const std::string& tag); 47 | bool WriteBinary(ostream_wrapper& out, const Binary& binary); 48 | } 49 | } 50 | 51 | #endif // EMITTERUTILS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 52 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/token.h: -------------------------------------------------------------------------------- 1 | #ifndef TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "mark.h" 11 | #include 12 | #include 13 | #include 14 | 15 | namespace YAML { 16 | const std::string TokenNames[] = { 17 | "DIRECTIVE", "DOC_START", "DOC_END", "BLOCK_SEQ_START", 18 | "BLOCK_MAP_START", "BLOCK_SEQ_END", "BLOCK_MAP_END", "BLOCK_ENTRY", 19 | "FLOW_SEQ_START", "FLOW_MAP_START", "FLOW_SEQ_END", "FLOW_MAP_END", 20 | "FLOW_MAP_COMPACT", "FLOW_ENTRY", "KEY", "VALUE", 21 | "ANCHOR", "ALIAS", "TAG", "SCALAR"}; 22 | 23 | struct Token { 24 | // enums 25 | enum STATUS { VALID, INVALID, UNVERIFIED }; 26 | enum TYPE { 27 | DIRECTIVE, 28 | DOC_START, 29 | DOC_END, 30 | BLOCK_SEQ_START, 31 | BLOCK_MAP_START, 32 | BLOCK_SEQ_END, 33 | BLOCK_MAP_END, 34 | BLOCK_ENTRY, 35 | FLOW_SEQ_START, 36 | FLOW_MAP_START, 37 | FLOW_SEQ_END, 38 | FLOW_MAP_END, 39 | FLOW_MAP_COMPACT, 40 | FLOW_ENTRY, 41 | KEY, 42 | VALUE, 43 | ANCHOR, 44 | ALIAS, 45 | TAG, 46 | PLAIN_SCALAR, 47 | NON_PLAIN_SCALAR 48 | }; 49 | 50 | // data 51 | Token(TYPE type_, const Mark& mark_) 52 | : status(VALID), type(type_), mark(mark_), value{}, params{}, data(0) {} 53 | 54 | friend std::ostream& operator<<(std::ostream& out, const Token& token) { 55 | out << TokenNames[token.type] << std::string(": ") << token.value; 56 | for (const std::string& param : token.params) 57 | out << std::string(" ") << param; 58 | return out; 59 | } 60 | 61 | STATUS status; 62 | TYPE type; 63 | Mark mark; 64 | std::string value; 65 | std::vector params; 66 | int data; 67 | }; 68 | } // namespace YAML 69 | 70 | #endif // TOKEN_H_62B23520_7C8E_11DE_8A39_0800200C9A66 71 | -------------------------------------------------------------------------------- /Source/UnrealYAML/Private/Node.cpp: -------------------------------------------------------------------------------- 1 | #include "Node.h" 2 | 3 | EYamlNodeType FYamlNode::Type() const { 4 | try { 5 | return static_cast(Node.Type()); 6 | } catch (YAML::InvalidNode) { 7 | UE_LOG(LogTemp, Warning, TEXT("Node was Invalid, returning default value for Type()!")) 8 | return EYamlNodeType::Undefined; 9 | } 10 | } 11 | 12 | EYamlEmitterStyle FYamlNode::Style() const { 13 | try { 14 | return static_cast(Node.Style()); 15 | } catch (YAML::InvalidNode) { 16 | UE_LOG(LogTemp, Warning, TEXT("Node was Invalid, returning default value for Style()!")) 17 | return EYamlEmitterStyle::Default; 18 | } 19 | } 20 | 21 | void FYamlNode::SetStyle(const EYamlEmitterStyle Style) { 22 | Node.SetStyle(static_cast(Style)); 23 | } 24 | 25 | bool FYamlNode::Is(const FYamlNode& Other) const { 26 | try { 27 | return Node.is(Other.Node); 28 | } catch (YAML::InvalidNode) { 29 | UE_LOG(LogTemp, Warning, TEXT("Node was Invalid, returning default value for Is() / Equals-Operation!")) 30 | return false; 31 | } 32 | } 33 | 34 | bool FYamlNode::Reset(const FYamlNode& Other) { 35 | try { 36 | Node.reset(Other.Node); 37 | return true; 38 | } catch (YAML::InvalidNode) { 39 | UE_LOG(LogTemp, Warning, TEXT("Node was Invalid and will not be Reset!")) 40 | return false; 41 | } 42 | } 43 | 44 | FString FYamlNode::Scalar() const { 45 | try { 46 | return FString(Node.Scalar().c_str()); 47 | } catch (YAML::InvalidNode) { 48 | UE_LOG(LogTemp, Warning, TEXT("Node was Invalid, returning default value for Scalar()")) 49 | return ""; 50 | } 51 | } 52 | 53 | FString FYamlNode::GetContent() const { 54 | std::stringstream Stream; 55 | Stream << Node; 56 | return UTF8_TO_TCHAR(Stream.str().c_str()); 57 | } 58 | 59 | int32 FYamlNode::Size() const { 60 | try { 61 | return Node.size(); 62 | } catch (YAML::InvalidNode) { 63 | UE_LOG(LogTemp, Warning, TEXT("Node was Invalid, returning default value for Size()")) 64 | return 0; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/ostream_wrapper.h: -------------------------------------------------------------------------------- 1 | #ifndef OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | namespace YAML { 16 | class YAML_CPP_API ostream_wrapper { 17 | public: 18 | ostream_wrapper(); 19 | explicit ostream_wrapper(std::ostream& stream); 20 | ostream_wrapper(const ostream_wrapper&) = delete; 21 | ostream_wrapper(ostream_wrapper&&) = delete; 22 | ostream_wrapper& operator=(const ostream_wrapper&) = delete; 23 | ostream_wrapper& operator=(ostream_wrapper&&) = delete; 24 | ~ostream_wrapper(); 25 | 26 | void write(const std::string& str); 27 | void write(const char* str, std::size_t size); 28 | 29 | void set_comment() { m_comment = true; } 30 | 31 | const char* str() const { 32 | if (m_pStream) { 33 | return nullptr; 34 | } else { 35 | m_buffer[m_pos] = '\0'; 36 | return &m_buffer[0]; 37 | } 38 | } 39 | 40 | std::size_t row() const { return m_row; } 41 | std::size_t col() const { return m_col; } 42 | std::size_t pos() const { return m_pos; } 43 | bool comment() const { return m_comment; } 44 | 45 | private: 46 | void update_pos(char ch); 47 | 48 | private: 49 | mutable std::vector m_buffer; 50 | std::ostream* const m_pStream; 51 | 52 | std::size_t m_pos; 53 | std::size_t m_row, m_col; 54 | bool m_comment; 55 | }; 56 | 57 | template 58 | inline ostream_wrapper& operator<<(ostream_wrapper& stream, 59 | const char (&str)[N]) { 60 | stream.write(str, N - 1); 61 | return stream; 62 | } 63 | 64 | inline ostream_wrapper& operator<<(ostream_wrapper& stream, 65 | const std::string& str) { 66 | stream.write(str); 67 | return stream; 68 | } 69 | 70 | inline ostream_wrapper& operator<<(ostream_wrapper& stream, char ch) { 71 | stream.write(&ch, 1); 72 | return stream; 73 | } 74 | } // namespace YAML 75 | 76 | #endif // OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 77 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/binary.h: -------------------------------------------------------------------------------- 1 | #ifndef BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | namespace YAML { 16 | YAML_CPP_API std::string EncodeBase64(const unsigned char *data, 17 | std::size_t size); 18 | YAML_CPP_API std::vector DecodeBase64(const std::string &input); 19 | 20 | class YAML_CPP_API Binary { 21 | public: 22 | Binary(const unsigned char *data_, std::size_t size_) 23 | : m_data{}, m_unownedData(data_), m_unownedSize(size_) {} 24 | Binary() : Binary(nullptr, 0) {} 25 | Binary(const Binary &) = default; 26 | Binary(Binary &&) = default; 27 | Binary &operator=(const Binary &) = default; 28 | Binary &operator=(Binary &&) = default; 29 | 30 | bool owned() const { return !m_unownedData; } 31 | std::size_t size() const { return owned() ? m_data.size() : m_unownedSize; } 32 | const unsigned char *data() const { 33 | return owned() ? &m_data[0] : m_unownedData; 34 | } 35 | 36 | void swap(std::vector &rhs) { 37 | if (m_unownedData) { 38 | m_data.swap(rhs); 39 | rhs.clear(); 40 | rhs.resize(m_unownedSize); 41 | std::copy(m_unownedData, m_unownedData + m_unownedSize, rhs.begin()); 42 | m_unownedData = nullptr; 43 | m_unownedSize = 0; 44 | } else { 45 | m_data.swap(rhs); 46 | } 47 | } 48 | 49 | bool operator==(const Binary &rhs) const { 50 | const std::size_t s = size(); 51 | if (s != rhs.size()) 52 | return false; 53 | const unsigned char *d1 = data(); 54 | const unsigned char *d2 = rhs.data(); 55 | for (std::size_t i = 0; i < s; i++) { 56 | if (*d1++ != *d2++) 57 | return false; 58 | } 59 | return true; 60 | } 61 | 62 | bool operator!=(const Binary &rhs) const { return !(*this == rhs); } 63 | 64 | private: 65 | std::vector m_data; 66 | const unsigned char *m_unownedData; 67 | std::size_t m_unownedSize; 68 | }; 69 | } // namespace YAML 70 | 71 | #endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 72 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/node/parse.h: -------------------------------------------------------------------------------- 1 | #ifndef VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | 16 | namespace YAML { 17 | class Node; 18 | 19 | /** 20 | * Loads the input string as a single YAML document. 21 | * 22 | * @throws {@link ParserException} if it is malformed. 23 | */ 24 | YAML_CPP_API Node Load(const std::string& input); 25 | 26 | /** 27 | * Loads the input string as a single YAML document. 28 | * 29 | * @throws {@link ParserException} if it is malformed. 30 | */ 31 | YAML_CPP_API Node Load(const char* input); 32 | 33 | /** 34 | * Loads the input stream as a single YAML document. 35 | * 36 | * @throws {@link ParserException} if it is malformed. 37 | */ 38 | YAML_CPP_API Node Load(std::istream& input); 39 | 40 | /** 41 | * Loads the input file as a single YAML document. 42 | * 43 | * @throws {@link ParserException} if it is malformed. 44 | * @throws {@link BadFile} if the file cannot be loaded. 45 | */ 46 | YAML_CPP_API Node LoadFile(const std::string& filename); 47 | 48 | /** 49 | * Loads the input string as a list of YAML documents. 50 | * 51 | * @throws {@link ParserException} if it is malformed. 52 | */ 53 | YAML_CPP_API std::vector LoadAll(const std::string& input); 54 | 55 | /** 56 | * Loads the input string as a list of YAML documents. 57 | * 58 | * @throws {@link ParserException} if it is malformed. 59 | */ 60 | YAML_CPP_API std::vector LoadAll(const char* input); 61 | 62 | /** 63 | * Loads the input stream as a list of YAML documents. 64 | * 65 | * @throws {@link ParserException} if it is malformed. 66 | */ 67 | YAML_CPP_API std::vector LoadAll(std::istream& input); 68 | 69 | /** 70 | * Loads the input file as a list of YAML documents. 71 | * 72 | * @throws {@link ParserException} if it is malformed. 73 | * @throws {@link BadFile} if the file cannot be loaded. 74 | */ 75 | YAML_CPP_API std::vector LoadAllFromFile(const std::string& filename); 76 | } // namespace YAML 77 | 78 | #endif // VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 79 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/stream.h: -------------------------------------------------------------------------------- 1 | #ifndef STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "mark.h" 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace YAML { 19 | 20 | class StreamCharSource; 21 | 22 | class Stream { 23 | public: 24 | friend class StreamCharSource; 25 | 26 | Stream(std::istream& input); 27 | Stream(const Stream&) = delete; 28 | Stream(Stream&&) = delete; 29 | Stream& operator=(const Stream&) = delete; 30 | Stream& operator=(Stream&&) = delete; 31 | ~Stream(); 32 | 33 | operator bool() const; 34 | bool operator!() const { return !static_cast(*this); } 35 | 36 | char peek() const; 37 | char get(); 38 | std::string get(int n); 39 | void eat(int n = 1); 40 | 41 | static char eof() { return 0x04; } 42 | 43 | const Mark mark() const { return m_mark; } 44 | int pos() const { return m_mark.pos; } 45 | int line() const { return m_mark.line; } 46 | int column() const { return m_mark.column; } 47 | void ResetColumn() { m_mark.column = 0; } 48 | 49 | private: 50 | enum CharacterSet { utf8, utf16le, utf16be, utf32le, utf32be }; 51 | 52 | std::istream& m_input; 53 | Mark m_mark; 54 | 55 | CharacterSet m_charSet; 56 | mutable std::deque m_readahead; 57 | unsigned char* const m_pPrefetched; 58 | mutable size_t m_nPrefetchedAvailable; 59 | mutable size_t m_nPrefetchedUsed; 60 | 61 | void AdvanceCurrent(); 62 | char CharAt(size_t i) const; 63 | bool ReadAheadTo(size_t i) const; 64 | bool _ReadAheadTo(size_t i) const; 65 | void StreamInUtf8() const; 66 | void StreamInUtf16() const; 67 | void StreamInUtf32() const; 68 | unsigned char GetNextByte() const; 69 | }; 70 | 71 | // CharAt 72 | // . Unchecked access 73 | inline char Stream::CharAt(size_t i) const { return m_readahead[i]; } 74 | 75 | inline bool Stream::ReadAheadTo(size_t i) const { 76 | if (m_readahead.size() > i) 77 | return true; 78 | return _ReadAheadTo(i); 79 | } 80 | } // namespace YAML 81 | 82 | #endif // STREAM_H_62B23520_7C8E_11DE_8A39_0800200C9A66 83 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/nodebuilder.h: -------------------------------------------------------------------------------- 1 | #ifndef NODE_NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define NODE_NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | #include "anchor.h" 13 | #include "emitterstyle.h" 14 | #include "eventhandler.h" 15 | #include "node/ptr.h" 16 | 17 | namespace YAML { 18 | namespace detail { 19 | class node; 20 | } // namespace detail 21 | struct Mark; 22 | } // namespace YAML 23 | 24 | namespace YAML { 25 | class Node; 26 | 27 | class NodeBuilder : public EventHandler { 28 | public: 29 | NodeBuilder(); 30 | NodeBuilder(const NodeBuilder&) = delete; 31 | NodeBuilder(NodeBuilder&&) = delete; 32 | NodeBuilder& operator=(const NodeBuilder&) = delete; 33 | NodeBuilder& operator=(NodeBuilder&&) = delete; 34 | ~NodeBuilder() override; 35 | 36 | Node Root(); 37 | 38 | void OnDocumentStart(const Mark& mark) override; 39 | void OnDocumentEnd() override; 40 | 41 | void OnNull(const Mark& mark, anchor_t anchor) override; 42 | void OnAlias(const Mark& mark, anchor_t anchor) override; 43 | void OnScalar(const Mark& mark, const std::string& tag, 44 | anchor_t anchor, const std::string& value) override; 45 | 46 | void OnSequenceStart(const Mark& mark, const std::string& tag, 47 | anchor_t anchor, EmitterStyle style) override; 48 | void OnSequenceEnd() override; 49 | 50 | void OnMapStart(const Mark& mark, const std::string& tag, 51 | anchor_t anchor, EmitterStyle style) override; 52 | void OnMapEnd() override; 53 | 54 | private: 55 | detail::node& Push(const Mark& mark, anchor_t anchor); 56 | void Push(detail::node& node); 57 | void Pop(); 58 | void RegisterAnchor(anchor_t anchor, detail::node& node); 59 | 60 | private: 61 | detail::shared_memory_holder m_pMemory; 62 | detail::node* m_pRoot; 63 | 64 | using Nodes = std::vector; 65 | Nodes m_stack; 66 | Nodes m_anchors; 67 | 68 | using PushedKey = std::pair; 69 | std::vector m_keys; 70 | std::size_t m_mapDepth; 71 | }; 72 | } // namespace YAML 73 | 74 | #endif // NODE_NODEBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 75 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/singledocparser.h: -------------------------------------------------------------------------------- 1 | #ifndef SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "anchor.h" 15 | 16 | namespace YAML { 17 | class CollectionStack; 18 | template class DepthGuard; // depthguard.h 19 | class EventHandler; 20 | class Node; 21 | class Scanner; 22 | struct Directives; 23 | struct Mark; 24 | struct Token; 25 | 26 | class SingleDocParser { 27 | public: 28 | SingleDocParser(Scanner& scanner, const Directives& directives); 29 | SingleDocParser(const SingleDocParser&) = delete; 30 | SingleDocParser(SingleDocParser&&) = delete; 31 | SingleDocParser& operator=(const SingleDocParser&) = delete; 32 | SingleDocParser& operator=(SingleDocParser&&) = delete; 33 | ~SingleDocParser(); 34 | 35 | void HandleDocument(EventHandler& eventHandler); 36 | 37 | private: 38 | void HandleNode(EventHandler& eventHandler); 39 | 40 | void HandleSequence(EventHandler& eventHandler); 41 | void HandleBlockSequence(EventHandler& eventHandler); 42 | void HandleFlowSequence(EventHandler& eventHandler); 43 | 44 | void HandleMap(EventHandler& eventHandler); 45 | void HandleBlockMap(EventHandler& eventHandler); 46 | void HandleFlowMap(EventHandler& eventHandler); 47 | void HandleCompactMap(EventHandler& eventHandler); 48 | void HandleCompactMapWithNoKey(EventHandler& eventHandler); 49 | 50 | void ParseProperties(std::string& tag, anchor_t& anchor, 51 | std::string& anchor_name); 52 | void ParseTag(std::string& tag); 53 | void ParseAnchor(anchor_t& anchor, std::string& anchor_name); 54 | 55 | anchor_t RegisterAnchor(const std::string& name); 56 | anchor_t LookupAnchor(const Mark& mark, const std::string& name) const; 57 | 58 | private: 59 | int depth = 0; 60 | Scanner& m_scanner; 61 | const Directives& m_directives; 62 | std::unique_ptr m_pCollectionStack; 63 | 64 | using Anchors = std::map; 65 | Anchors m_anchors; 66 | 67 | anchor_t m_curAnchor; 68 | }; 69 | } // namespace YAML 70 | 71 | #endif // SINGLEDOCPARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 72 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/scanscalar.h: -------------------------------------------------------------------------------- 1 | #ifndef SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | #include "regex_yaml.h" 13 | #include "stream.h" 14 | 15 | namespace YAML { 16 | enum CHOMP { STRIP = -1, CLIP, KEEP }; 17 | enum ACTION { NONE, BREAK, THROW }; 18 | enum FOLD { DONT_FOLD, FOLD_BLOCK, FOLD_FLOW }; 19 | 20 | struct ScanScalarParams { 21 | ScanScalarParams() 22 | : end(nullptr), 23 | eatEnd(false), 24 | indent(0), 25 | detectIndent(false), 26 | eatLeadingWhitespace(0), 27 | escape(0), 28 | fold(DONT_FOLD), 29 | trimTrailingSpaces(0), 30 | chomp(CLIP), 31 | onDocIndicator(NONE), 32 | onTabInIndentation(NONE), 33 | leadingSpaces(false) {} 34 | 35 | // input: 36 | const RegEx* end; // what condition ends this scalar? 37 | // unowned. 38 | bool eatEnd; // should we eat that condition when we see it? 39 | int indent; // what level of indentation should be eaten and ignored? 40 | bool detectIndent; // should we try to autodetect the indent? 41 | bool eatLeadingWhitespace; // should we continue eating this delicious 42 | // indentation after 'indent' spaces? 43 | char escape; // what character do we escape on (i.e., slash or single quote) 44 | // (0 for none) 45 | FOLD fold; // how do we fold line ends? 46 | bool trimTrailingSpaces; // do we remove all trailing spaces (at the very 47 | // end) 48 | CHOMP chomp; // do we strip, clip, or keep trailing newlines (at the very 49 | // end) 50 | // Note: strip means kill all, clip means keep at most one, keep means keep 51 | // all 52 | ACTION onDocIndicator; // what do we do if we see a document indicator? 53 | ACTION onTabInIndentation; // what do we do if we see a tab where we should 54 | // be seeing indentation spaces 55 | 56 | // output: 57 | bool leadingSpaces; 58 | }; 59 | 60 | std::string ScanScalar(Stream& INPUT, ScanScalarParams& params); 61 | } 62 | 63 | #endif // SCANSCALAR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 64 | -------------------------------------------------------------------------------- /Source/UnrealYAML/Private/NodeHelpers.cpp: -------------------------------------------------------------------------------- 1 | #include "NodeHelpers.h" 2 | 3 | #include "node/parse.h" 4 | #include "HAL/FileManagerGeneric.h" 5 | 6 | // At least here we can use macros :) 7 | #define DEFINE_YAML_CONVERSIONS(Type, FancyName) \ 8 | FYamlNode UYamlNodeHelpers::MakeFrom##FancyName(Type Value) { \ 9 | return FYamlNode(Value); \ 10 | } \ 11 | FYamlNode UYamlNodeHelpers::MakeFrom##FancyName##Array(const TArray& Value) { \ 12 | return FYamlNode(Value); \ 13 | } \ 14 | FYamlNode UYamlNodeHelpers::MakeFromInt##FancyName##Map(const TMap& Value) { \ 15 | return FYamlNode(Value); \ 16 | } \ 17 | FYamlNode UYamlNodeHelpers::MakeFromString##FancyName##Map(const TMap& Value) { \ 18 | return FYamlNode(Value); \ 19 | } \ 20 | bool UYamlNodeHelpers::As##FancyName(const FYamlNode& Node, Type Default, Type& Value) { \ 21 | const auto Out = Node.AsOptional(); \ 22 | const bool Success = Out.IsSet(); \ 23 | Value = Out.Get(Default); \ 24 | return Success; \ 25 | } \ 26 | bool UYamlNodeHelpers::As##FancyName##Array(const FYamlNode& Node, const TArray& Default, TArray& Value) { \ 27 | const auto Out = Node.AsOptional>(); \ 28 | const bool Success = Out.IsSet(); \ 29 | Value = Out.Get(Default); \ 30 | return Success; \ 31 | } \ 32 | bool UYamlNodeHelpers::AsInt##FancyName##Map(const FYamlNode& Node, const TMap& Default, TMap& Value) { \ 33 | const auto Out = Node.AsOptional>(); \ 34 | const bool Success = Out.IsSet(); \ 35 | Value = Out.Get(Default); \ 36 | return Success; \ 37 | } \ 38 | bool UYamlNodeHelpers::AsString##FancyName##Map(const FYamlNode& Node, const TMap& Default, TMap& Value) { \ 39 | const auto Out = Node.AsOptional>(); \ 40 | const bool Success = Out.IsSet(); \ 41 | Value = Out.Get(Default); \ 42 | return Success; \ 43 | } 44 | 45 | DEFINE_YAML_CONVERSIONS(int32, Int) 46 | DEFINE_YAML_CONVERSIONS(int64, Long) 47 | DEFINE_YAML_CONVERSIONS(uint8, Byte) 48 | DEFINE_YAML_CONVERSIONS(float, Float) 49 | DEFINE_YAML_CONVERSIONS(bool, Bool) 50 | DEFINE_YAML_CONVERSIONS(FString, String) 51 | DEFINE_YAML_CONVERSIONS(FText, Text) 52 | DEFINE_YAML_CONVERSIONS(FVector, Vector) 53 | DEFINE_YAML_CONVERSIONS(FQuat, Quat) 54 | DEFINE_YAML_CONVERSIONS(FTransform, Transform) 55 | 56 | #undef DEFINE_YAML_CONVERSIONS 57 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/depthguard.h: -------------------------------------------------------------------------------- 1 | #ifndef DEPTH_GUARD_H_00000000000000000000000000000000000000000000000000000000 2 | #define DEPTH_GUARD_H_00000000000000000000000000000000000000000000000000000000 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "exceptions.h" 11 | 12 | namespace YAML { 13 | 14 | /** 15 | * @brief The DeepRecursion class 16 | * An exception class which is thrown by DepthGuard. Ideally it should be 17 | * a member of DepthGuard. However, DepthGuard is a templated class which means 18 | * that any catch points would then need to know the template parameters. It is 19 | * simpler for clients to not have to know at the catch point what was the 20 | * maximum depth. 21 | */ 22 | class DeepRecursion : public ParserException { 23 | public: 24 | virtual ~DeepRecursion() = default; 25 | 26 | DeepRecursion(int depth, const Mark& mark_, const std::string& msg_); 27 | 28 | // Returns the recursion depth when the exception was thrown 29 | int depth() const { 30 | return m_depth; 31 | } 32 | 33 | private: 34 | int m_depth = 0; 35 | }; 36 | 37 | /** 38 | * @brief The DepthGuard class 39 | * DepthGuard takes a reference to an integer. It increments the integer upon 40 | * construction of DepthGuard and decrements the integer upon destruction. 41 | * 42 | * If the integer would be incremented past max_depth, then an exception is 43 | * thrown. This is ideally geared toward guarding against deep recursion. 44 | * 45 | * @param max_depth 46 | * compile-time configurable maximum depth. 47 | */ 48 | template 49 | class DepthGuard final { 50 | public: 51 | DepthGuard(int & depth_, const Mark& mark_, const std::string& msg_) : m_depth(depth_) { 52 | ++m_depth; 53 | if ( max_depth <= m_depth ) { 54 | throw DeepRecursion{m_depth, mark_, msg_}; 55 | } 56 | } 57 | 58 | DepthGuard(const DepthGuard & copy_ctor) = delete; 59 | DepthGuard(DepthGuard && move_ctor) = delete; 60 | DepthGuard & operator=(const DepthGuard & copy_assign) = delete; 61 | DepthGuard & operator=(DepthGuard && move_assign) = delete; 62 | 63 | ~DepthGuard() { 64 | --m_depth; 65 | } 66 | 67 | int current_depth() const { 68 | return m_depth; 69 | } 70 | 71 | private: 72 | int & m_depth; 73 | }; 74 | 75 | } // namespace YAML 76 | 77 | #endif // DEPTH_GUARD_H_00000000000000000000000000000000000000000000000000000000 78 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/parser.h: -------------------------------------------------------------------------------- 1 | #ifndef PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | namespace YAML { 14 | class EventHandler; 15 | class Node; 16 | class Scanner; 17 | struct Directives; 18 | struct Token; 19 | 20 | /** 21 | * A parser turns a stream of bytes into one stream of "events" per YAML 22 | * document in the input stream. 23 | */ 24 | class YAML_CPP_API Parser { 25 | public: 26 | /** Constructs an empty parser (with no input. */ 27 | Parser(); 28 | 29 | Parser(const Parser&) = delete; 30 | Parser(Parser&&) = delete; 31 | Parser& operator=(const Parser&) = delete; 32 | Parser& operator=(Parser&&) = delete; 33 | 34 | /** 35 | * Constructs a parser from the given input stream. The input stream must 36 | * live as long as the parser. 37 | */ 38 | explicit Parser(std::istream& in); 39 | 40 | ~Parser(); 41 | 42 | /** Evaluates to true if the parser has some valid input to be read. */ 43 | explicit operator bool() const; 44 | 45 | /** 46 | * Resets the parser with the given input stream. Any existing state is 47 | * erased. 48 | */ 49 | void Load(std::istream& in); 50 | 51 | /** 52 | * Handles the next document by calling events on the {@code eventHandler}. 53 | * 54 | * @throw a ParserException on error. 55 | * @return false if there are no more documents 56 | */ 57 | bool HandleNextDocument(EventHandler& eventHandler); 58 | 59 | void PrintTokens(std::ostream& out); 60 | 61 | private: 62 | /** 63 | * Reads any directives that are next in the queue, setting the internal 64 | * {@code m_pDirectives} state. 65 | */ 66 | void ParseDirectives(); 67 | 68 | void HandleDirective(const Token& token); 69 | 70 | /** 71 | * Handles a "YAML" directive, which should be of the form 'major.minor' (like 72 | * a version number). 73 | */ 74 | void HandleYamlDirective(const Token& token); 75 | 76 | /** 77 | * Handles a "TAG" directive, which should be of the form 'handle prefix', 78 | * where 'handle' is converted to 'prefix' in the file. 79 | */ 80 | void HandleTagDirective(const Token& token); 81 | 82 | private: 83 | std::unique_ptr m_pScanner; 84 | std::unique_ptr m_pDirectives; 85 | }; 86 | } // namespace YAML 87 | 88 | #endif // PARSER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 89 | -------------------------------------------------------------------------------- /Source/UnrealYAML/Private/Tests/Parse.cpp: -------------------------------------------------------------------------------- 1 | #include "Misc/AutomationTest.h" 2 | #include "Parsing.h" 3 | #include "Inputs.h" 4 | 5 | #if WITH_DEV_AUTOMATION_TESTS 6 | 7 | // For Engine Versions <5 8 | #ifndef UE_PI 9 | #define UE_PI PI 10 | #endif 11 | 12 | #if ENGINE_MAJOR_VERSION >= 5 13 | IMPLEMENT_SIMPLE_AUTOMATION_TEST(Parsing, "UnrealYAML.Parsing", 14 | EAutomationTestFlags_ApplicationContextMask | EAutomationTestFlags::SmokeFilter) 15 | #else 16 | IMPLEMENT_SIMPLE_AUTOMATION_TEST(Parsing, "UnrealYAML.Parsing", 17 | EAutomationTestFlags::ApplicationContextMask | EAutomationTestFlags::SmokeFilter) 18 | #endif 19 | 20 | bool Parsing::RunTest(const FString& Parameters) { 21 | // From String 22 | { 23 | FYamlNode Node; 24 | TestTrue("Parse Empty", UYamlParsing::ParseYaml(EmptyYaml, Node)); 25 | TestTrue("Parse Simple", UYamlParsing::ParseYaml(SimpleYaml, Node)); 26 | TestTrue("Parse Complex", UYamlParsing::ParseYaml(ComplexYaml, Node)); 27 | TestFalse("Parse Erroneous", UYamlParsing::ParseYaml(ErroneousYaml, Node)); 28 | } 29 | 30 | // Simple 31 | { 32 | FYamlNode Node; 33 | UYamlParsing::ParseYaml(SimpleYaml, Node); 34 | 35 | TestEqual("Parse String", Node["str"].As(), "A String"); 36 | TestEqual("Parse Integer", Node["int"].As(), 42); 37 | TestTrue("Parse Boolean", Node["bool"].As()); 38 | TestEqual("Parse Array", Node["arr"].As>(), {1, 2, 3}); 39 | TestTrue("Parse Map", Node["map"].As>() 40 | .OrderIndependentCompareEqual(TMap{{"a", 1}, {"b", 2}})); 41 | } 42 | 43 | { 44 | FYamlNode Node; 45 | UYamlParsing::ParseYaml(ComplexYaml, Node); 46 | 47 | TestTrue("Parse nested Array", 48 | Node["nested"].IsSequence() && 49 | Node["nested"][0].As>() == TArray{1, 2, 3} && 50 | Node["nested"][1].As>() == TArray{"a", "b", "c", "d"} && 51 | Node["nested"][2].IsNull() 52 | ); 53 | TestTrue("Parse mixed Array", 54 | Node["mixed"][0].As() && 55 | FMath::IsNearlyEqual(Node["mixed"][1].As(), UE_PI) 56 | ); 57 | TestTrue("Parse Color and Set", 58 | Node["struct"].IsMap() && 59 | Node["struct"]["color"].As() == FColor::Magenta && 60 | Node["struct"]["set"].As>().Difference(TSet{0, 1, 3, 5, 6}).Num() == 0 61 | ); 62 | } 63 | 64 | return !HasAnyErrors(); 65 | } 66 | 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/regex_yaml.h: -------------------------------------------------------------------------------- 1 | #ifndef REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | namespace YAML { 16 | class Stream; 17 | 18 | enum REGEX_OP { 19 | REGEX_EMPTY, 20 | REGEX_MATCH, 21 | REGEX_RANGE, 22 | REGEX_OR, 23 | REGEX_AND, 24 | REGEX_NOT, 25 | REGEX_SEQ 26 | }; 27 | 28 | // simplified regular expressions 29 | // . Only straightforward matches (no repeated characters) 30 | // . Only matches from start of string 31 | class YAML_CPP_API RegEx { 32 | public: 33 | RegEx(); 34 | explicit RegEx(char ch); 35 | RegEx(char a, char z); 36 | RegEx(const std::string& str, REGEX_OP op = REGEX_SEQ); 37 | ~RegEx() = default; 38 | 39 | friend YAML_CPP_API RegEx operator!(const RegEx& ex); 40 | friend YAML_CPP_API RegEx operator|(const RegEx& ex1, const RegEx& ex2); 41 | friend YAML_CPP_API RegEx operator&(const RegEx& ex1, const RegEx& ex2); 42 | friend YAML_CPP_API RegEx operator+(const RegEx& ex1, const RegEx& ex2); 43 | 44 | bool Matches(char ch) const; 45 | bool Matches(const std::string& str) const; 46 | bool Matches(const Stream& in) const; 47 | template 48 | bool Matches(const Source& source) const; 49 | 50 | int Match(const std::string& str) const; 51 | int Match(const Stream& in) const; 52 | template 53 | int Match(const Source& source) const; 54 | 55 | private: 56 | explicit RegEx(REGEX_OP op); 57 | 58 | template 59 | bool IsValidSource(const Source& source) const; 60 | template 61 | int MatchUnchecked(const Source& source) const; 62 | 63 | template 64 | int MatchOpEmpty(const Source& source) const; 65 | template 66 | int MatchOpMatch(const Source& source) const; 67 | template 68 | int MatchOpRange(const Source& source) const; 69 | template 70 | int MatchOpOr(const Source& source) const; 71 | template 72 | int MatchOpAnd(const Source& source) const; 73 | template 74 | int MatchOpNot(const Source& source) const; 75 | template 76 | int MatchOpSeq(const Source& source) const; 77 | 78 | private: 79 | REGEX_OP m_op; 80 | char m_a{}; 81 | char m_z{}; 82 | std::vector m_params; 83 | }; 84 | } // namespace YAML 85 | 86 | #include "regeximpl.h" 87 | 88 | #endif // REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66 89 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/node/detail/iterator.h: -------------------------------------------------------------------------------- 1 | #ifndef VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | 11 | #include "node/detail/node_iterator.h" 12 | #include "node/node.h" 13 | #include "node/ptr.h" 14 | #include 15 | #include 16 | 17 | 18 | namespace YAML { 19 | namespace detail { 20 | struct iterator_value; 21 | 22 | template 23 | class iterator_base { 24 | 25 | private: 26 | template 27 | friend class iterator_base; 28 | struct enabler {}; 29 | using base_type = node_iterator; 30 | 31 | struct proxy { 32 | explicit proxy(const V& x) : m_ref(x) {} 33 | V* operator->() { return std::addressof(m_ref); } 34 | operator V*() { return std::addressof(m_ref); } 35 | 36 | V m_ref; 37 | }; 38 | 39 | public: 40 | using iterator_category = std::forward_iterator_tag; 41 | using value_type = V; 42 | using difference_type = std::ptrdiff_t; 43 | using pointer = V*; 44 | using reference = V; 45 | 46 | public: 47 | iterator_base() : m_iterator(), m_pMemory() {} 48 | explicit iterator_base(base_type rhs, shared_memory_holder pMemory) 49 | : m_iterator(rhs), m_pMemory(pMemory) {} 50 | 51 | template 52 | iterator_base(const iterator_base& rhs, 53 | typename std::enable_if::value, 54 | enabler>::type = enabler()) 55 | : m_iterator(rhs.m_iterator), m_pMemory(rhs.m_pMemory) {} 56 | 57 | iterator_base& operator++() { 58 | ++m_iterator; 59 | return *this; 60 | } 61 | 62 | iterator_base operator++(int) { 63 | iterator_base iterator_pre(*this); 64 | ++(*this); 65 | return iterator_pre; 66 | } 67 | 68 | template 69 | bool operator==(const iterator_base& rhs) const { 70 | return m_iterator == rhs.m_iterator; 71 | } 72 | 73 | template 74 | bool operator!=(const iterator_base& rhs) const { 75 | return m_iterator != rhs.m_iterator; 76 | } 77 | 78 | value_type operator*() const { 79 | const typename base_type::value_type& v = *m_iterator; 80 | if (v.pNode) 81 | return value_type(Node(*v, m_pMemory)); 82 | if (v.first && v.second) 83 | return value_type(Node(*v.first, m_pMemory), Node(*v.second, m_pMemory)); 84 | return value_type(); 85 | } 86 | 87 | proxy operator->() const { return proxy(**this); } 88 | 89 | private: 90 | base_type m_iterator; 91 | shared_memory_holder m_pMemory; 92 | }; 93 | } // namespace detail 94 | } // namespace YAML 95 | 96 | #endif // VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 97 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/nodeevents.cpp: -------------------------------------------------------------------------------- 1 | #include "nodeevents.h" 2 | #include "eventhandler.h" 3 | #include "mark.h" 4 | #include "node/detail/node.h" 5 | #include "node/detail/node_iterator.h" 6 | #include "node/node.h" 7 | #include "node/type.h" 8 | 9 | namespace YAML { 10 | void NodeEvents::AliasManager::RegisterReference(const detail::node& node) { 11 | m_anchorByIdentity.insert(std::make_pair(node.ref(), _CreateNewAnchor())); 12 | } 13 | 14 | anchor_t NodeEvents::AliasManager::LookupAnchor( 15 | const detail::node& node) const { 16 | auto it = m_anchorByIdentity.find(node.ref()); 17 | if (it == m_anchorByIdentity.end()) 18 | return 0; 19 | return it->second; 20 | } 21 | 22 | NodeEvents::NodeEvents(const Node& node) 23 | : m_pMemory(node.m_pMemory), m_root(node.m_pNode), m_refCount{} { 24 | if (m_root) 25 | Setup(*m_root); 26 | } 27 | 28 | void NodeEvents::Setup(const detail::node& node) { 29 | int& refCount = m_refCount[node.ref()]; 30 | refCount++; 31 | if (refCount > 1) 32 | return; 33 | 34 | if (node.type() == NodeType::Sequence) { 35 | for (auto element : node) 36 | Setup(*element); 37 | } else if (node.type() == NodeType::Map) { 38 | for (auto element : node) { 39 | Setup(*element.first); 40 | Setup(*element.second); 41 | } 42 | } 43 | } 44 | 45 | void NodeEvents::Emit(EventHandler& handler) { 46 | AliasManager am; 47 | 48 | handler.OnDocumentStart(Mark()); 49 | if (m_root) 50 | Emit(*m_root, handler, am); 51 | handler.OnDocumentEnd(); 52 | } 53 | 54 | void NodeEvents::Emit(const detail::node& node, EventHandler& handler, 55 | AliasManager& am) const { 56 | anchor_t anchor = NullAnchor; 57 | if (IsAliased(node)) { 58 | anchor = am.LookupAnchor(node); 59 | if (anchor) { 60 | handler.OnAlias(Mark(), anchor); 61 | return; 62 | } 63 | 64 | am.RegisterReference(node); 65 | anchor = am.LookupAnchor(node); 66 | } 67 | 68 | switch (node.type()) { 69 | case NodeType::Undefined: 70 | break; 71 | case NodeType::Null: 72 | handler.OnNull(Mark(), anchor); 73 | break; 74 | case NodeType::Scalar: 75 | handler.OnScalar(Mark(), node.tag(), anchor, node.scalar()); 76 | break; 77 | case NodeType::Sequence: 78 | handler.OnSequenceStart(Mark(), node.tag(), anchor, node.style()); 79 | for (auto element : node) 80 | Emit(*element, handler, am); 81 | handler.OnSequenceEnd(); 82 | break; 83 | case NodeType::Map: 84 | handler.OnMapStart(Mark(), node.tag(), anchor, node.style()); 85 | for (auto element : node) { 86 | Emit(*element.first, handler, am); 87 | Emit(*element.second, handler, am); 88 | } 89 | handler.OnMapEnd(); 90 | break; 91 | } 92 | } 93 | 94 | bool NodeEvents::IsAliased(const detail::node& node) const { 95 | auto it = m_refCount.find(node.ref()); 96 | return it != m_refCount.end() && it->second > 1; 97 | } 98 | } // namespace YAML 99 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/contrib/graphbuilderadapter.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "anchor.h" 15 | #include "contrib/anchordict.h" 16 | #include "contrib/graphbuilder.h" 17 | #include "emitterstyle.h" 18 | #include "eventhandler.h" 19 | 20 | namespace YAML { 21 | class GraphBuilderInterface; 22 | struct Mark; 23 | } // namespace YAML 24 | 25 | namespace YAML { 26 | class GraphBuilderAdapter : public EventHandler { 27 | public: 28 | GraphBuilderAdapter(GraphBuilderInterface& builder) 29 | : m_builder(builder), 30 | m_containers{}, 31 | m_anchors{}, 32 | m_pRootNode(nullptr), 33 | m_pKeyNode(nullptr) {} 34 | GraphBuilderAdapter(const GraphBuilderAdapter&) = delete; 35 | GraphBuilderAdapter(GraphBuilderAdapter&&) = delete; 36 | GraphBuilderAdapter& operator=(const GraphBuilderAdapter&) = delete; 37 | GraphBuilderAdapter& operator=(GraphBuilderAdapter&&) = delete; 38 | 39 | virtual void OnDocumentStart(const Mark& mark) { (void)mark; } 40 | virtual void OnDocumentEnd() {} 41 | 42 | virtual void OnNull(const Mark& mark, anchor_t anchor); 43 | virtual void OnAlias(const Mark& mark, anchor_t anchor); 44 | virtual void OnScalar(const Mark& mark, const std::string& tag, 45 | anchor_t anchor, const std::string& value); 46 | 47 | virtual void OnSequenceStart(const Mark& mark, const std::string& tag, 48 | anchor_t anchor, EmitterStyle style); 49 | virtual void OnSequenceEnd(); 50 | 51 | virtual void OnMapStart(const Mark& mark, const std::string& tag, 52 | anchor_t anchor, EmitterStyle style); 53 | virtual void OnMapEnd(); 54 | 55 | void* RootNode() const { return m_pRootNode; } 56 | 57 | private: 58 | struct ContainerFrame { 59 | ContainerFrame(void* pSequence) 60 | : pContainer(pSequence), pPrevKeyNode(&sequenceMarker) {} 61 | ContainerFrame(void* pMap, void* pPreviousKeyNode) 62 | : pContainer(pMap), pPrevKeyNode(pPreviousKeyNode) {} 63 | 64 | void* pContainer; 65 | void* pPrevKeyNode; 66 | 67 | bool isMap() const { return pPrevKeyNode != &sequenceMarker; } 68 | 69 | private: 70 | static int sequenceMarker; 71 | }; 72 | typedef std::stack ContainerStack; 73 | typedef AnchorDict AnchorMap; 74 | 75 | GraphBuilderInterface& m_builder; 76 | ContainerStack m_containers; 77 | AnchorMap m_anchors; 78 | void* m_pRootNode; 79 | void* m_pKeyNode; 80 | 81 | void* GetCurrentParent() const; 82 | void RegisterAnchor(anchor_t anchor, void* pNode); 83 | void DispositionNode(void* pNode); 84 | }; 85 | } // namespace YAML 86 | 87 | #endif // GRAPHBUILDERADAPTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 88 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/contrib/graphbuilderadapter.cpp: -------------------------------------------------------------------------------- 1 | #include "graphbuilderadapter.h" 2 | #include "contrib/graphbuilder.h" 3 | 4 | namespace YAML { 5 | struct Mark; 6 | 7 | int GraphBuilderAdapter::ContainerFrame::sequenceMarker; 8 | 9 | void GraphBuilderAdapter::OnNull(const Mark &mark, anchor_t anchor) { 10 | void *pParent = GetCurrentParent(); 11 | void *pNode = m_builder.NewNull(mark, pParent); 12 | RegisterAnchor(anchor, pNode); 13 | 14 | DispositionNode(pNode); 15 | } 16 | 17 | void GraphBuilderAdapter::OnAlias(const Mark &mark, anchor_t anchor) { 18 | void *pReffedNode = m_anchors.Get(anchor); 19 | DispositionNode(m_builder.AnchorReference(mark, pReffedNode)); 20 | } 21 | 22 | void GraphBuilderAdapter::OnScalar(const Mark &mark, const std::string &tag, 23 | anchor_t anchor, const std::string &value) { 24 | void *pParent = GetCurrentParent(); 25 | void *pNode = m_builder.NewScalar(mark, tag, pParent, value); 26 | RegisterAnchor(anchor, pNode); 27 | 28 | DispositionNode(pNode); 29 | } 30 | 31 | void GraphBuilderAdapter::OnSequenceStart(const Mark &mark, 32 | const std::string &tag, 33 | anchor_t anchor, 34 | EmitterStyle /* style */) { 35 | void *pNode = m_builder.NewSequence(mark, tag, GetCurrentParent()); 36 | m_containers.push(ContainerFrame(pNode)); 37 | RegisterAnchor(anchor, pNode); 38 | } 39 | 40 | void GraphBuilderAdapter::OnSequenceEnd() { 41 | void *pSequence = m_containers.top().pContainer; 42 | m_containers.pop(); 43 | 44 | DispositionNode(pSequence); 45 | } 46 | 47 | void GraphBuilderAdapter::OnMapStart(const Mark &mark, const std::string &tag, 48 | anchor_t anchor, 49 | EmitterStyle /* style */) { 50 | void *pNode = m_builder.NewMap(mark, tag, GetCurrentParent()); 51 | m_containers.push(ContainerFrame(pNode, m_pKeyNode)); 52 | m_pKeyNode = nullptr; 53 | RegisterAnchor(anchor, pNode); 54 | } 55 | 56 | void GraphBuilderAdapter::OnMapEnd() { 57 | void *pMap = m_containers.top().pContainer; 58 | m_pKeyNode = m_containers.top().pPrevKeyNode; 59 | m_containers.pop(); 60 | DispositionNode(pMap); 61 | } 62 | 63 | void *GraphBuilderAdapter::GetCurrentParent() const { 64 | if (m_containers.empty()) { 65 | return nullptr; 66 | } 67 | return m_containers.top().pContainer; 68 | } 69 | 70 | void GraphBuilderAdapter::RegisterAnchor(anchor_t anchor, void *pNode) { 71 | if (anchor) { 72 | m_anchors.Register(anchor, pNode); 73 | } 74 | } 75 | 76 | void GraphBuilderAdapter::DispositionNode(void *pNode) { 77 | if (m_containers.empty()) { 78 | m_pRootNode = pNode; 79 | return; 80 | } 81 | 82 | void *pContainer = m_containers.top().pContainer; 83 | if (m_containers.top().isMap()) { 84 | if (m_pKeyNode) { 85 | m_builder.AssignInMap(pContainer, m_pKeyNode, pNode); 86 | m_pKeyNode = nullptr; 87 | } else { 88 | m_pKeyNode = pNode; 89 | } 90 | } else { 91 | m_builder.AppendToSequence(pContainer, pNode); 92 | } 93 | } 94 | } // namespace YAML 95 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/setting.h: -------------------------------------------------------------------------------- 1 | #ifndef SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "noexcept.h" 11 | #include 12 | #include 13 | #include 14 | 15 | namespace YAML { 16 | 17 | class SettingChangeBase { 18 | public: 19 | virtual ~SettingChangeBase() = default; 20 | virtual void pop() = 0; 21 | }; 22 | 23 | template 24 | class Setting { 25 | public: 26 | Setting() : m_value() {} 27 | Setting(const T& value) : m_value() { set(value); } 28 | 29 | const T get() const { return m_value; } 30 | std::unique_ptr set(const T& value); 31 | void restore(const Setting& oldSetting) { m_value = oldSetting.get(); } 32 | 33 | private: 34 | T m_value; 35 | }; 36 | 37 | template 38 | class SettingChange : public SettingChangeBase { 39 | public: 40 | SettingChange(Setting* pSetting) 41 | : m_pCurSetting(pSetting), 42 | m_oldSetting(*pSetting) // copy old setting to save its state 43 | {} 44 | SettingChange(const SettingChange&) = delete; 45 | SettingChange(SettingChange&&) = delete; 46 | SettingChange& operator=(const SettingChange&) = delete; 47 | SettingChange& operator=(SettingChange&&) = delete; 48 | 49 | void pop() override { m_pCurSetting->restore(m_oldSetting); } 50 | 51 | private: 52 | Setting* m_pCurSetting; 53 | Setting m_oldSetting; 54 | }; 55 | 56 | template 57 | inline std::unique_ptr Setting::set(const T& value) { 58 | std::unique_ptr pChange(new SettingChange(this)); 59 | m_value = value; 60 | return pChange; 61 | } 62 | 63 | class SettingChanges { 64 | public: 65 | SettingChanges() : m_settingChanges{} {} 66 | SettingChanges(const SettingChanges&) = delete; 67 | SettingChanges(SettingChanges&&) YAML_CPP_NOEXCEPT = default; 68 | SettingChanges& operator=(const SettingChanges&) = delete; 69 | SettingChanges& operator=(SettingChanges&& rhs) YAML_CPP_NOEXCEPT { 70 | if (this == &rhs) 71 | return *this; 72 | 73 | clear(); 74 | std::swap(m_settingChanges, rhs.m_settingChanges); 75 | 76 | return *this; 77 | } 78 | ~SettingChanges() { clear(); } 79 | 80 | void clear() YAML_CPP_NOEXCEPT { 81 | restore(); 82 | m_settingChanges.clear(); 83 | } 84 | 85 | void restore() YAML_CPP_NOEXCEPT { 86 | for (const auto& setting : m_settingChanges) 87 | setting->pop(); 88 | } 89 | 90 | void push(std::unique_ptr pSettingChange) { 91 | m_settingChanges.push_back(std::move(pSettingChange)); 92 | } 93 | 94 | private: 95 | using setting_changes = std::vector>; 96 | setting_changes m_settingChanges; 97 | }; 98 | } // namespace YAML 99 | 100 | #endif // SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66 101 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/traits.h: -------------------------------------------------------------------------------- 1 | #ifndef TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace YAML { 16 | template 17 | struct is_numeric { 18 | enum { value = false }; 19 | }; 20 | 21 | template <> 22 | struct is_numeric { 23 | enum { value = true }; 24 | }; 25 | template <> 26 | struct is_numeric { 27 | enum { value = true }; 28 | }; 29 | template <> 30 | struct is_numeric { 31 | enum { value = true }; 32 | }; 33 | template <> 34 | struct is_numeric { 35 | enum { value = true }; 36 | }; 37 | template <> 38 | struct is_numeric { 39 | enum { value = true }; 40 | }; 41 | template <> 42 | struct is_numeric { 43 | enum { value = true }; 44 | }; 45 | template <> 46 | struct is_numeric { 47 | enum { value = true }; 48 | }; 49 | template <> 50 | struct is_numeric { 51 | enum { value = true }; 52 | }; 53 | #if defined(_MSC_VER) && (_MSC_VER < 1310) 54 | template <> 55 | struct is_numeric<__int64> { 56 | enum { value = true }; 57 | }; 58 | template <> 59 | struct is_numeric { 60 | enum { value = true }; 61 | }; 62 | #else 63 | template <> 64 | struct is_numeric { 65 | enum { value = true }; 66 | }; 67 | template <> 68 | struct is_numeric { 69 | enum { value = true }; 70 | }; 71 | #endif 72 | template <> 73 | struct is_numeric { 74 | enum { value = true }; 75 | }; 76 | template <> 77 | struct is_numeric { 78 | enum { value = true }; 79 | }; 80 | template <> 81 | struct is_numeric { 82 | enum { value = true }; 83 | }; 84 | 85 | template 86 | struct enable_if_c { 87 | using type = T; 88 | }; 89 | 90 | template 91 | struct enable_if_c {}; 92 | 93 | template 94 | struct enable_if : public enable_if_c {}; 95 | 96 | template 97 | struct disable_if_c { 98 | using type = T; 99 | }; 100 | 101 | template 102 | struct disable_if_c {}; 103 | 104 | template 105 | struct disable_if : public disable_if_c {}; 106 | } 107 | 108 | template 109 | struct is_streamable { 110 | template 111 | static auto test(int) 112 | -> decltype(std::declval() << std::declval(), std::true_type()); 113 | 114 | template 115 | static auto test(...) -> std::false_type; 116 | 117 | static const bool value = decltype(test(0))::value; 118 | }; 119 | 120 | template 121 | struct streamable_to_string { 122 | static std::string impl(const Key& key) { 123 | std::stringstream ss; 124 | ss << key; 125 | return ss.str(); 126 | } 127 | }; 128 | 129 | template 130 | struct streamable_to_string { 131 | static std::string impl(const Key&) { 132 | return ""; 133 | } 134 | }; 135 | #endif // TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 136 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/node/detail/node_ref.h: -------------------------------------------------------------------------------- 1 | #ifndef VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | 11 | #include "node/type.h" 12 | #include "node/ptr.h" 13 | #include "node/detail/node_data.h" 14 | 15 | namespace YAML { 16 | namespace detail { 17 | class node_ref { 18 | public: 19 | node_ref() : m_pData(new node_data) {} 20 | node_ref(const node_ref&) = delete; 21 | node_ref& operator=(const node_ref&) = delete; 22 | 23 | bool is_defined() const { return m_pData->is_defined(); } 24 | const Mark& mark() const { return m_pData->mark(); } 25 | NodeType type() const { return m_pData->type(); } 26 | const std::string& scalar() const { return m_pData->scalar(); } 27 | const std::string& tag() const { return m_pData->tag(); } 28 | EmitterStyle style() const { return m_pData->style(); } 29 | 30 | void mark_defined() { m_pData->mark_defined(); } 31 | void set_data(const node_ref& rhs) { m_pData = rhs.m_pData; } 32 | 33 | void set_mark(const Mark& mark) { m_pData->set_mark(mark); } 34 | void set_type(NodeType type) { m_pData->set_type(type); } 35 | void set_tag(const std::string& tag) { m_pData->set_tag(tag); } 36 | void set_null() { m_pData->set_null(); } 37 | void set_scalar(const std::string& scalar) { m_pData->set_scalar(scalar); } 38 | void set_style(EmitterStyle style) { m_pData->set_style(style); } 39 | 40 | // size/iterator 41 | std::size_t size() const { return m_pData->size(); } 42 | 43 | const_node_iterator begin() const { 44 | return static_cast(*m_pData).begin(); 45 | } 46 | node_iterator begin() { return m_pData->begin(); } 47 | 48 | const_node_iterator end() const { 49 | return static_cast(*m_pData).end(); 50 | } 51 | node_iterator end() { return m_pData->end(); } 52 | 53 | // sequence 54 | void push_back(node& node, shared_memory_holder pMemory) { 55 | m_pData->push_back(node, pMemory); 56 | } 57 | void insert(node& key, node& value, shared_memory_holder pMemory) { 58 | m_pData->insert(key, value, pMemory); 59 | } 60 | 61 | // indexing 62 | template 63 | node* get(const Key& key, shared_memory_holder pMemory) const { 64 | return static_cast(*m_pData).get(key, pMemory); 65 | } 66 | template 67 | node& get(const Key& key, shared_memory_holder pMemory) { 68 | return m_pData->get(key, pMemory); 69 | } 70 | template 71 | bool remove(const Key& key, shared_memory_holder pMemory) { 72 | return m_pData->remove(key, pMemory); 73 | } 74 | 75 | node* get(node& key, shared_memory_holder pMemory) const { 76 | return static_cast(*m_pData).get(key, pMemory); 77 | } 78 | node& get(node& key, shared_memory_holder pMemory) { 79 | return m_pData->get(key, pMemory); 80 | } 81 | bool remove(node& key, shared_memory_holder pMemory) { 82 | return m_pData->remove(key, pMemory); 83 | } 84 | 85 | // map 86 | template 87 | void force_insert(const Key& key, const Value& value, 88 | shared_memory_holder pMemory) { 89 | m_pData->force_insert(key, value, pMemory); 90 | } 91 | 92 | private: 93 | shared_node_data m_pData; 94 | }; 95 | } 96 | } 97 | 98 | #endif // VALUE_DETAIL_NODE_REF_H_62B23520_7C8E_11DE_8A39_0800200C9A66 99 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/parser.cpp: -------------------------------------------------------------------------------- 1 | #include "parser.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "directives.h" // IWYU pragma: keep 7 | #include "scanner.h" // IWYU pragma: keep 8 | #include "singledocparser.h" 9 | #include "token.h" 10 | #include "exceptions.h" // IWYU pragma: keep 11 | 12 | namespace YAML { 13 | class EventHandler; 14 | 15 | Parser::Parser() : m_pScanner{}, m_pDirectives{} {} 16 | 17 | Parser::Parser(std::istream& in) : Parser() { Load(in); } 18 | 19 | Parser::~Parser() = default; 20 | 21 | Parser::operator bool() const { return m_pScanner && !m_pScanner->empty(); } 22 | 23 | void Parser::Load(std::istream& in) { 24 | m_pScanner.reset(new Scanner(in)); 25 | m_pDirectives.reset(new Directives); 26 | } 27 | 28 | bool Parser::HandleNextDocument(EventHandler& eventHandler) { 29 | if (!m_pScanner) 30 | return false; 31 | 32 | ParseDirectives(); 33 | if (m_pScanner->empty()) { 34 | return false; 35 | } 36 | 37 | SingleDocParser sdp(*m_pScanner, *m_pDirectives); 38 | sdp.HandleDocument(eventHandler); 39 | return true; 40 | } 41 | 42 | void Parser::ParseDirectives() { 43 | bool readDirective = false; 44 | 45 | while (!m_pScanner->empty()) { 46 | Token& token = m_pScanner->peek(); 47 | if (token.type != Token::DIRECTIVE) { 48 | break; 49 | } 50 | 51 | // we keep the directives from the last document if none are specified; 52 | // but if any directives are specific, then we reset them 53 | if (!readDirective) { 54 | m_pDirectives.reset(new Directives); 55 | } 56 | 57 | readDirective = true; 58 | HandleDirective(token); 59 | m_pScanner->pop(); 60 | } 61 | } 62 | 63 | void Parser::HandleDirective(const Token& token) { 64 | if (token.value == "YAML") { 65 | HandleYamlDirective(token); 66 | } else if (token.value == "TAG") { 67 | HandleTagDirective(token); 68 | } 69 | } 70 | 71 | void Parser::HandleYamlDirective(const Token& token) { 72 | if (token.params.size() != 1) { 73 | throw ParserException(token.mark, ErrorMsg::YAML_DIRECTIVE_ARGS); 74 | } 75 | 76 | if (!m_pDirectives->version.isDefault) { 77 | throw ParserException(token.mark, ErrorMsg::REPEATED_YAML_DIRECTIVE); 78 | } 79 | 80 | std::stringstream str(token.params[0]); 81 | str >> m_pDirectives->version.major; 82 | str.get(); 83 | str >> m_pDirectives->version.minor; 84 | if (!str || str.peek() != EOF) { 85 | throw ParserException( 86 | token.mark, std::string(ErrorMsg::YAML_VERSION) + token.params[0]); 87 | } 88 | 89 | if (m_pDirectives->version.major > 1) { 90 | throw ParserException(token.mark, ErrorMsg::YAML_MAJOR_VERSION); 91 | } 92 | 93 | m_pDirectives->version.isDefault = false; 94 | // TODO: warning on major == 1, minor > 2? 95 | } 96 | 97 | void Parser::HandleTagDirective(const Token& token) { 98 | if (token.params.size() != 2) 99 | throw ParserException(token.mark, ErrorMsg::TAG_DIRECTIVE_ARGS); 100 | 101 | const std::string& handle = token.params[0]; 102 | const std::string& prefix = token.params[1]; 103 | if (m_pDirectives->tags.find(handle) != m_pDirectives->tags.end()) { 104 | throw ParserException(token.mark, ErrorMsg::REPEATED_TAG_DIRECTIVE); 105 | } 106 | 107 | m_pDirectives->tags[handle] = prefix; 108 | } 109 | 110 | void Parser::PrintTokens(std::ostream& out) { 111 | if (!m_pScanner) { 112 | return; 113 | } 114 | 115 | while (!m_pScanner->empty()) { 116 | out << m_pScanner->peek() << "\n"; 117 | m_pScanner->pop(); 118 | } 119 | } 120 | } // namespace YAML 121 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/binary.cpp: -------------------------------------------------------------------------------- 1 | #include "binary.h" 2 | 3 | #include 4 | 5 | namespace YAML { 6 | static const char encoding[] = 7 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 8 | 9 | std::string EncodeBase64(const unsigned char *data, std::size_t size) { 10 | const char PAD = '='; 11 | 12 | std::string ret; 13 | ret.resize(4 * size / 3 + 3); 14 | char *out = &ret[0]; 15 | 16 | std::size_t chunks = size / 3; 17 | std::size_t remainder = size % 3; 18 | 19 | for (std::size_t i = 0; i < chunks; i++, data += 3) { 20 | *out++ = encoding[data[0] >> 2]; 21 | *out++ = encoding[((data[0] & 0x3) << 4) | (data[1] >> 4)]; 22 | *out++ = encoding[((data[1] & 0xf) << 2) | (data[2] >> 6)]; 23 | *out++ = encoding[data[2] & 0x3f]; 24 | } 25 | 26 | switch (remainder) { 27 | case 0: 28 | break; 29 | case 1: 30 | *out++ = encoding[data[0] >> 2]; 31 | *out++ = encoding[((data[0] & 0x3) << 4)]; 32 | *out++ = PAD; 33 | *out++ = PAD; 34 | break; 35 | case 2: 36 | *out++ = encoding[data[0] >> 2]; 37 | *out++ = encoding[((data[0] & 0x3) << 4) | (data[1] >> 4)]; 38 | *out++ = encoding[((data[1] & 0xf) << 2)]; 39 | *out++ = PAD; 40 | break; 41 | } 42 | 43 | ret.resize(out - &ret[0]); 44 | return ret; 45 | } 46 | 47 | static const unsigned char decoding[] = { 48 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 49 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 50 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 255, 51 | 255, 255, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 52 | 255, 0, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 53 | 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 54 | 25, 255, 255, 255, 255, 255, 255, 26, 27, 28, 29, 30, 31, 32, 33, 55 | 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 56 | 49, 50, 51, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 57 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 58 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 59 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 60 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 61 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 63 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 64 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 65 | 255, 66 | }; 67 | 68 | std::vector DecodeBase64(const std::string &input) { 69 | using ret_type = std::vector; 70 | if (input.empty()) 71 | return ret_type(); 72 | 73 | ret_type ret(3 * input.size() / 4 + 1); 74 | unsigned char *out = &ret[0]; 75 | 76 | unsigned value = 0; 77 | for (std::size_t i = 0, cnt = 0; i < input.size(); i++) { 78 | if (std::isspace(input[i])) { 79 | // skip newlines 80 | continue; 81 | } 82 | unsigned char d = decoding[static_cast(input[i])]; 83 | if (d == 255) 84 | return ret_type(); 85 | 86 | value = (value << 6) | d; 87 | if (cnt % 4 == 3) { 88 | *out++ = value >> 16; 89 | if (i > 0 && input[i - 1] != '=') 90 | *out++ = value >> 8; 91 | if (input[i] != '=') 92 | *out++ = value; 93 | } 94 | ++cnt; 95 | } 96 | 97 | ret.resize(out - &ret[0]); 98 | return ret; 99 | } 100 | } // namespace YAML 101 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/emitfromevents.cpp: -------------------------------------------------------------------------------- 1 | #include "emitfromevents.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "emitter.h" 7 | #include "emittermanip.h" 8 | #include "null.h" 9 | 10 | namespace YAML { 11 | struct Mark; 12 | } // namespace YAML 13 | 14 | namespace { 15 | std::string ToString(YAML::anchor_t anchor) { 16 | std::stringstream stream; 17 | stream << anchor; 18 | return stream.str(); 19 | } 20 | } // namespace 21 | 22 | namespace YAML { 23 | EmitFromEvents::EmitFromEvents(Emitter& emitter) 24 | : m_emitter(emitter), m_stateStack{} {} 25 | 26 | void EmitFromEvents::OnDocumentStart(const Mark&) {} 27 | 28 | void EmitFromEvents::OnDocumentEnd() {} 29 | 30 | void EmitFromEvents::OnNull(const Mark&, anchor_t anchor) { 31 | BeginNode(); 32 | EmitProps("", anchor); 33 | m_emitter << Null; 34 | } 35 | 36 | void EmitFromEvents::OnAlias(const Mark&, anchor_t anchor) { 37 | BeginNode(); 38 | m_emitter << Alias(ToString(anchor)); 39 | } 40 | 41 | void EmitFromEvents::OnScalar(const Mark&, const std::string& tag, 42 | anchor_t anchor, const std::string& value) { 43 | BeginNode(); 44 | EmitProps(tag, anchor); 45 | m_emitter << value; 46 | } 47 | 48 | void EmitFromEvents::OnSequenceStart(const Mark&, const std::string& tag, 49 | anchor_t anchor, 50 | EmitterStyle style) { 51 | BeginNode(); 52 | EmitProps(tag, anchor); 53 | switch (style) { 54 | case EmitterStyle::Block: 55 | m_emitter << EmitterManip::Block; 56 | break; 57 | case EmitterStyle::Flow: 58 | m_emitter << EmitterManip::Flow; 59 | break; 60 | default: 61 | break; 62 | } 63 | // Restore the global settings to eliminate the override from node style 64 | m_emitter.RestoreGlobalModifiedSettings(); 65 | m_emitter << EmitterManip::BeginSeq; 66 | m_stateStack.push(State::WaitingForSequenceEntry); 67 | } 68 | 69 | void EmitFromEvents::OnSequenceEnd() { 70 | m_emitter << EmitterManip::EndSeq; 71 | assert(m_stateStack.top() == State::WaitingForSequenceEntry); 72 | m_stateStack.pop(); 73 | } 74 | 75 | void EmitFromEvents::OnMapStart(const Mark&, const std::string& tag, 76 | anchor_t anchor, EmitterStyle style) { 77 | BeginNode(); 78 | EmitProps(tag, anchor); 79 | switch (style) { 80 | case EmitterStyle::Block: 81 | m_emitter << EmitterManip::Block; 82 | break; 83 | case EmitterStyle::Flow: 84 | m_emitter << EmitterManip::Flow; 85 | break; 86 | default: 87 | break; 88 | } 89 | // Restore the global settings to eliminate the override from node style 90 | m_emitter.RestoreGlobalModifiedSettings(); 91 | m_emitter << EmitterManip::BeginMap; 92 | m_stateStack.push(State::WaitingForKey); 93 | } 94 | 95 | void EmitFromEvents::OnMapEnd() { 96 | m_emitter << EmitterManip::EndMap; 97 | assert(m_stateStack.top() == State::WaitingForKey); 98 | m_stateStack.pop(); 99 | } 100 | 101 | void EmitFromEvents::BeginNode() { 102 | if (m_stateStack.empty()) 103 | return; 104 | 105 | switch (m_stateStack.top()) { 106 | case State::WaitingForKey: 107 | m_emitter << EmitterManip::Key; 108 | m_stateStack.top() = State::WaitingForValue; 109 | break; 110 | case State::WaitingForValue: 111 | m_emitter << EmitterManip::Value; 112 | m_stateStack.top() = State::WaitingForKey; 113 | break; 114 | default: 115 | break; 116 | } 117 | } 118 | 119 | void EmitFromEvents::EmitProps(const std::string& tag, anchor_t anchor) { 120 | if (!tag.empty() && tag != "?" && tag != "!") 121 | m_emitter << VerbatimTag(tag); 122 | if (anchor) 123 | m_emitter << Anchor(ToString(anchor)); 124 | } 125 | } // namespace YAML 126 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/nodebuilder.cpp: -------------------------------------------------------------------------------- 1 | #include "nodebuilder.h" 2 | 3 | #include 4 | 5 | #include "node/detail/node.h" 6 | #include "node/impl.h" 7 | #include "node/node.h" 8 | #include "node/type.h" 9 | 10 | namespace YAML { 11 | struct Mark; 12 | 13 | NodeBuilder::NodeBuilder() 14 | : m_pMemory(new detail::memory_holder), 15 | m_pRoot(nullptr), 16 | m_stack{}, 17 | m_anchors{}, 18 | m_keys{}, 19 | m_mapDepth(0) { 20 | m_anchors.push_back(nullptr); // since the anchors start at 1 21 | } 22 | 23 | NodeBuilder::~NodeBuilder() = default; 24 | 25 | Node NodeBuilder::Root() { 26 | if (!m_pRoot) 27 | return Node(); 28 | 29 | return Node(*m_pRoot, m_pMemory); 30 | } 31 | 32 | void NodeBuilder::OnDocumentStart(const Mark&) {} 33 | 34 | void NodeBuilder::OnDocumentEnd() {} 35 | 36 | void NodeBuilder::OnNull(const Mark& mark, anchor_t anchor) { 37 | detail::node& node = Push(mark, anchor); 38 | node.set_null(); 39 | Pop(); 40 | } 41 | 42 | void NodeBuilder::OnAlias(const Mark& /* mark */, anchor_t anchor) { 43 | detail::node& node = *m_anchors[anchor]; 44 | Push(node); 45 | Pop(); 46 | } 47 | 48 | void NodeBuilder::OnScalar(const Mark& mark, const std::string& tag, 49 | anchor_t anchor, const std::string& value) { 50 | detail::node& node = Push(mark, anchor); 51 | node.set_scalar(value); 52 | node.set_tag(tag); 53 | Pop(); 54 | } 55 | 56 | void NodeBuilder::OnSequenceStart(const Mark& mark, const std::string& tag, 57 | anchor_t anchor, EmitterStyle style) { 58 | detail::node& node = Push(mark, anchor); 59 | node.set_tag(tag); 60 | node.set_type(NodeType::Sequence); 61 | node.set_style(style); 62 | } 63 | 64 | void NodeBuilder::OnSequenceEnd() { Pop(); } 65 | 66 | void NodeBuilder::OnMapStart(const Mark& mark, const std::string& tag, 67 | anchor_t anchor, EmitterStyle style) { 68 | detail::node& node = Push(mark, anchor); 69 | node.set_type(NodeType::Map); 70 | node.set_tag(tag); 71 | node.set_style(style); 72 | m_mapDepth++; 73 | } 74 | 75 | void NodeBuilder::OnMapEnd() { 76 | assert(m_mapDepth > 0); 77 | m_mapDepth--; 78 | Pop(); 79 | } 80 | 81 | detail::node& NodeBuilder::Push(const Mark& mark, anchor_t anchor) { 82 | detail::node& node = m_pMemory->create_node(); 83 | node.set_mark(mark); 84 | RegisterAnchor(anchor, node); 85 | Push(node); 86 | return node; 87 | } 88 | 89 | void NodeBuilder::Push(detail::node& node) { 90 | const bool needsKey = 91 | (!m_stack.empty() && m_stack.back()->type() == NodeType::Map && 92 | m_keys.size() < m_mapDepth); 93 | 94 | m_stack.push_back(&node); 95 | if (needsKey) 96 | m_keys.emplace_back(&node, false); 97 | } 98 | 99 | void NodeBuilder::Pop() { 100 | assert(!m_stack.empty()); 101 | if (m_stack.size() == 1) { 102 | m_pRoot = m_stack[0]; 103 | m_stack.pop_back(); 104 | return; 105 | } 106 | 107 | detail::node& node = *m_stack.back(); 108 | m_stack.pop_back(); 109 | 110 | detail::node& collection = *m_stack.back(); 111 | 112 | if (collection.type() == NodeType::Sequence) { 113 | collection.push_back(node, m_pMemory); 114 | } else if (collection.type() == NodeType::Map) { 115 | assert(!m_keys.empty()); 116 | PushedKey& key = m_keys.back(); 117 | if (key.second) { 118 | collection.insert(*key.first, node, m_pMemory); 119 | m_keys.pop_back(); 120 | } else { 121 | key.second = true; 122 | } 123 | } else { 124 | assert(false); 125 | m_stack.clear(); 126 | } 127 | } 128 | 129 | void NodeBuilder::RegisterAnchor(anchor_t anchor, detail::node& node) { 130 | if (anchor) { 131 | assert(anchor == m_anchors.size()); 132 | m_anchors.push_back(&node); 133 | } 134 | } 135 | } // namespace YAML 136 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/simplekey.cpp: -------------------------------------------------------------------------------- 1 | #include "scanner.h" 2 | #include "token.h" 3 | 4 | namespace YAML { 5 | struct Mark; 6 | 7 | Scanner::SimpleKey::SimpleKey(const Mark& mark_, std::size_t flowLevel_) 8 | : mark(mark_), 9 | flowLevel(flowLevel_), 10 | pIndent(nullptr), 11 | pMapStart(nullptr), 12 | pKey(nullptr) {} 13 | 14 | void Scanner::SimpleKey::Validate() { 15 | // Note: pIndent will *not* be garbage here; 16 | // we "garbage collect" them so we can 17 | // always refer to them 18 | if (pIndent) 19 | pIndent->status = IndentMarker::VALID; 20 | if (pMapStart) 21 | pMapStart->status = Token::VALID; 22 | if (pKey) 23 | pKey->status = Token::VALID; 24 | } 25 | 26 | void Scanner::SimpleKey::Invalidate() { 27 | if (pIndent) 28 | pIndent->status = IndentMarker::INVALID; 29 | if (pMapStart) 30 | pMapStart->status = Token::INVALID; 31 | if (pKey) 32 | pKey->status = Token::INVALID; 33 | } 34 | 35 | // CanInsertPotentialSimpleKey 36 | bool Scanner::CanInsertPotentialSimpleKey() const { 37 | if (!m_simpleKeyAllowed) 38 | return false; 39 | 40 | return !ExistsActiveSimpleKey(); 41 | } 42 | 43 | // ExistsActiveSimpleKey 44 | // . Returns true if there's a potential simple key at our flow level 45 | // (there's allowed at most one per flow level, i.e., at the start of the flow 46 | // start token) 47 | bool Scanner::ExistsActiveSimpleKey() const { 48 | if (m_simpleKeys.empty()) 49 | return false; 50 | 51 | const SimpleKey& key = m_simpleKeys.top(); 52 | return key.flowLevel == GetFlowLevel(); 53 | } 54 | 55 | // InsertPotentialSimpleKey 56 | // . If we can, add a potential simple key to the queue, 57 | // and save it on a stack. 58 | void Scanner::InsertPotentialSimpleKey() { 59 | if (!CanInsertPotentialSimpleKey()) 60 | return; 61 | 62 | SimpleKey key(INPUT.mark(), GetFlowLevel()); 63 | 64 | // first add a map start, if necessary 65 | if (InBlockContext()) { 66 | key.pIndent = PushIndentTo(INPUT.column(), IndentMarker::MAP); 67 | if (key.pIndent) { 68 | key.pIndent->status = IndentMarker::UNKNOWN; 69 | key.pMapStart = key.pIndent->pStartToken; 70 | key.pMapStart->status = Token::UNVERIFIED; 71 | } 72 | } 73 | 74 | // then add the (now unverified) key 75 | m_tokens.push(Token(Token::KEY, INPUT.mark())); 76 | key.pKey = &m_tokens.back(); 77 | key.pKey->status = Token::UNVERIFIED; 78 | 79 | m_simpleKeys.push(key); 80 | } 81 | 82 | // InvalidateSimpleKey 83 | // . Automatically invalidate the simple key in our flow level 84 | void Scanner::InvalidateSimpleKey() { 85 | if (m_simpleKeys.empty()) 86 | return; 87 | 88 | // grab top key 89 | SimpleKey& key = m_simpleKeys.top(); 90 | if (key.flowLevel != GetFlowLevel()) 91 | return; 92 | 93 | key.Invalidate(); 94 | m_simpleKeys.pop(); 95 | } 96 | 97 | // VerifySimpleKey 98 | // . Determines whether the latest simple key to be added is valid, 99 | // and if so, makes it valid. 100 | bool Scanner::VerifySimpleKey() { 101 | if (m_simpleKeys.empty()) 102 | return false; 103 | 104 | // grab top key 105 | SimpleKey key = m_simpleKeys.top(); 106 | 107 | // only validate if we're in the correct flow level 108 | if (key.flowLevel != GetFlowLevel()) 109 | return false; 110 | 111 | m_simpleKeys.pop(); 112 | 113 | bool isValid = true; 114 | 115 | // needs to be less than 1024 characters and inline 116 | if (INPUT.line() != key.mark.line || INPUT.pos() - key.mark.pos > 1024) 117 | isValid = false; 118 | 119 | // invalidate key 120 | if (isValid) 121 | key.Validate(); 122 | else 123 | key.Invalidate(); 124 | 125 | return isValid; 126 | } 127 | 128 | void Scanner::PopAllSimpleKeys() { 129 | while (!m_simpleKeys.empty()) 130 | m_simpleKeys.pop(); 131 | } 132 | } // namespace YAML 133 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/exp.cpp: -------------------------------------------------------------------------------- 1 | #include "exp.h" 2 | 3 | #include 4 | 5 | #include "stream.h" 6 | #include "exceptions.h" // IWYU pragma: keep 7 | 8 | namespace YAML { 9 | struct Mark; 10 | } // namespace YAML 11 | 12 | namespace YAML { 13 | namespace Exp { 14 | unsigned ParseHex(const std::string& str, const Mark& mark) { 15 | unsigned value = 0; 16 | for (char ch : str) { 17 | int digit = 0; 18 | if ('a' <= ch && ch <= 'f') 19 | digit = ch - 'a' + 10; 20 | else if ('A' <= ch && ch <= 'F') 21 | digit = ch - 'A' + 10; 22 | else if ('0' <= ch && ch <= '9') 23 | digit = ch - '0'; 24 | else 25 | throw ParserException(mark, ErrorMsg::INVALID_HEX); 26 | 27 | value = (value << 4) + digit; 28 | } 29 | 30 | return value; 31 | } 32 | 33 | std::string Str(unsigned ch) { return std::string(1, static_cast(ch)); } 34 | 35 | // Escape 36 | // . Translates the next 'codeLength' characters into a hex number and returns 37 | // the result. 38 | // . Throws if it's not actually hex. 39 | std::string Escape(Stream& in, int codeLength) { 40 | // grab string 41 | std::string str; 42 | for (int i = 0; i < codeLength; i++) 43 | str += in.get(); 44 | 45 | // get the value 46 | unsigned value = ParseHex(str, in.mark()); 47 | 48 | // legal unicode? 49 | if ((value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF) { 50 | std::stringstream msg; 51 | msg << ErrorMsg::INVALID_UNICODE << value; 52 | throw ParserException(in.mark(), msg.str()); 53 | } 54 | 55 | // now break it up into chars 56 | if (value <= 0x7F) 57 | return Str(value); 58 | 59 | if (value <= 0x7FF) 60 | return Str(0xC0 + (value >> 6)) + Str(0x80 + (value & 0x3F)); 61 | 62 | if (value <= 0xFFFF) 63 | return Str(0xE0 + (value >> 12)) + Str(0x80 + ((value >> 6) & 0x3F)) + 64 | Str(0x80 + (value & 0x3F)); 65 | 66 | return Str(0xF0 + (value >> 18)) + Str(0x80 + ((value >> 12) & 0x3F)) + 67 | Str(0x80 + ((value >> 6) & 0x3F)) + Str(0x80 + (value & 0x3F)); 68 | } 69 | 70 | // Escape 71 | // . Escapes the sequence starting 'in' (it must begin with a '\' or single 72 | // quote) 73 | // and returns the result. 74 | // . Throws if it's an unknown escape character. 75 | std::string Escape(Stream& in) { 76 | // eat slash 77 | char escape = in.get(); 78 | 79 | // switch on escape character 80 | char ch = in.get(); 81 | 82 | // first do single quote, since it's easier 83 | if (escape == '\'' && ch == '\'') 84 | return "\'"; 85 | 86 | // now do the slash (we're not gonna check if it's a slash - you better pass 87 | // one!) 88 | switch (ch) { 89 | case '0': 90 | return std::string(1, '\x00'); 91 | case 'a': 92 | return "\x07"; 93 | case 'b': 94 | return "\x08"; 95 | case 't': 96 | case '\t': 97 | return "\x09"; 98 | case 'n': 99 | return "\x0A"; 100 | case 'v': 101 | return "\x0B"; 102 | case 'f': 103 | return "\x0C"; 104 | case 'r': 105 | return "\x0D"; 106 | case 'e': 107 | return "\x1B"; 108 | case ' ': 109 | return R"( )"; 110 | case '\"': 111 | return "\""; 112 | case '\'': 113 | return "\'"; 114 | case '\\': 115 | return "\\"; 116 | case '/': 117 | return "/"; 118 | case 'N': 119 | return "\x85"; 120 | case '_': 121 | return "\xA0"; 122 | case 'L': 123 | return "\xE2\x80\xA8"; // LS (#x2028) 124 | case 'P': 125 | return "\xE2\x80\xA9"; // PS (#x2029) 126 | case 'x': 127 | return Escape(in, 2); 128 | case 'u': 129 | return Escape(in, 4); 130 | case 'U': 131 | return Escape(in, 8); 132 | } 133 | 134 | std::stringstream msg; 135 | throw ParserException(in.mark(), std::string(ErrorMsg::INVALID_ESCAPE) + ch); 136 | } 137 | } // namespace Exp 138 | } // namespace YAML 139 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/emittermanip.h: -------------------------------------------------------------------------------- 1 | #ifndef EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | 12 | namespace YAML { 13 | enum class EmitterManip { 14 | // general manipulators 15 | Auto, 16 | TagByKind, 17 | Newline, 18 | 19 | // output character set 20 | EmitNonAscii, 21 | EscapeNonAscii, 22 | EscapeAsJson, 23 | 24 | // string manipulators 25 | // Auto, // duplicate 26 | SingleQuoted, 27 | DoubleQuoted, 28 | Literal, 29 | 30 | // null manipulators 31 | LowerNull, 32 | UpperNull, 33 | CamelNull, 34 | TildeNull, 35 | 36 | // bool manipulators 37 | YesNoBool, // yes, no 38 | TrueFalseBool, // true, false 39 | OnOffBool, // on, off 40 | UpperCase, // TRUE, N 41 | LowerCase, // f, yes 42 | CamelCase, // No, Off 43 | LongBool, // yes, On 44 | ShortBool, // y, t 45 | 46 | // int manipulators 47 | Dec, 48 | Hex, 49 | Oct, 50 | 51 | // document manipulators 52 | BeginDoc, 53 | EndDoc, 54 | 55 | // sequence manipulators 56 | BeginSeq, 57 | EndSeq, 58 | Flow, 59 | Block, 60 | 61 | // map manipulators 62 | BeginMap, 63 | EndMap, 64 | Key, 65 | Value, 66 | // Flow, // duplicate 67 | // Block, // duplicate 68 | // Auto, // duplicate 69 | LongKey 70 | }; 71 | 72 | struct _Indent { 73 | _Indent(int value_) : value(value_) {} 74 | int value; 75 | }; 76 | 77 | inline _Indent Indent(int value) { return _Indent(value); } 78 | 79 | struct _Alias { 80 | _Alias(const std::string& content_) : content(content_) {} 81 | std::string content; 82 | }; 83 | 84 | inline _Alias Alias(const std::string& content) { return _Alias(content); } 85 | 86 | struct _Anchor { 87 | _Anchor(const std::string& content_) : content(content_) {} 88 | std::string content; 89 | }; 90 | 91 | inline _Anchor Anchor(const std::string& content) { return _Anchor(content); } 92 | 93 | struct _Tag { 94 | enum class Type {Verbatim, PrimaryHandle, NamedHandle}; 95 | 96 | explicit _Tag(const std::string& prefix_, const std::string& content_, Type type_) 97 | : prefix(prefix_), content(content_), type(type_) {} 98 | std::string prefix; 99 | std::string content; 100 | Type type; 101 | }; 102 | 103 | inline _Tag VerbatimTag(const std::string& content) { 104 | return _Tag("", content, _Tag::Type::Verbatim); 105 | } 106 | 107 | inline _Tag LocalTag(const std::string& content) { 108 | return _Tag("", content, _Tag::Type::PrimaryHandle); 109 | } 110 | 111 | inline _Tag LocalTag(const std::string& prefix, const std::string content) { 112 | return _Tag(prefix, content, _Tag::Type::NamedHandle); 113 | } 114 | 115 | inline _Tag SecondaryTag(const std::string& content) { 116 | return _Tag("", content, _Tag::Type::NamedHandle); 117 | } 118 | 119 | struct _Comment { 120 | _Comment(const std::string& content_) : content(content_) {} 121 | std::string content; 122 | }; 123 | 124 | inline _Comment Comment(const std::string& content) { return _Comment(content); } 125 | 126 | struct _Precision { 127 | _Precision(int floatPrecision_, int doublePrecision_) 128 | : floatPrecision(floatPrecision_), doublePrecision(doublePrecision_) {} 129 | 130 | int floatPrecision; 131 | int doublePrecision; 132 | }; 133 | 134 | inline _Precision FloatPrecision(int n) { return _Precision(n, -1); } 135 | 136 | inline _Precision DoublePrecision(int n) { return _Precision(-1, n); } 137 | 138 | inline _Precision Precision(int n) { return _Precision(n, n); } 139 | } 140 | 141 | #endif // EMITTERMANIP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 142 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/node/detail/node_data.h: -------------------------------------------------------------------------------- 1 | #ifndef VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | 17 | #include "node/detail/node_iterator.h" 18 | #include "node/iterator.h" 19 | #include "node/ptr.h" 20 | #include "node/type.h" 21 | 22 | namespace YAML { 23 | namespace detail { 24 | class node; 25 | } // namespace detail 26 | } // namespace YAML 27 | 28 | namespace YAML { 29 | namespace detail { 30 | class YAML_CPP_API node_data { 31 | public: 32 | node_data(); 33 | node_data(const node_data&) = delete; 34 | node_data& operator=(const node_data&) = delete; 35 | 36 | void mark_defined(); 37 | void set_mark(const Mark& mark); 38 | void set_type(NodeType type); 39 | void set_tag(const std::string& tag); 40 | void set_null(); 41 | void set_scalar(const std::string& scalar); 42 | void set_style(EmitterStyle style); 43 | 44 | bool is_defined() const { return m_isDefined; } 45 | const Mark& mark() const { return m_mark; } 46 | NodeType type() const { 47 | return m_isDefined ? m_type : NodeType::Undefined; 48 | } 49 | const std::string& scalar() const { return m_scalar; } 50 | const std::string& tag() const { return m_tag; } 51 | EmitterStyle style() const { return m_style; } 52 | 53 | // size/iterator 54 | std::size_t size() const; 55 | 56 | const_node_iterator begin() const; 57 | node_iterator begin(); 58 | 59 | const_node_iterator end() const; 60 | node_iterator end(); 61 | 62 | // sequence 63 | void push_back(node& node, const shared_memory_holder& pMemory); 64 | void insert(node& key, node& value, const shared_memory_holder& pMemory); 65 | 66 | // indexing 67 | template 68 | node* get(const Key& key, shared_memory_holder pMemory) const; 69 | template 70 | node& get(const Key& key, shared_memory_holder pMemory); 71 | template 72 | bool remove(const Key& key, shared_memory_holder pMemory); 73 | 74 | node* get(node& key, const shared_memory_holder& pMemory) const; 75 | node& get(node& key, const shared_memory_holder& pMemory); 76 | bool remove(node& key, const shared_memory_holder& pMemory); 77 | 78 | // map 79 | template 80 | void force_insert(const Key& key, const Value& value, 81 | shared_memory_holder pMemory); 82 | 83 | public: 84 | static const std::string& empty_scalar(); 85 | 86 | private: 87 | void compute_seq_size() const; 88 | void compute_map_size() const; 89 | 90 | void reset_sequence(); 91 | void reset_map(); 92 | 93 | void insert_map_pair(node& key, node& value); 94 | void convert_to_map(const shared_memory_holder& pMemory); 95 | void convert_sequence_to_map(const shared_memory_holder& pMemory); 96 | 97 | template 98 | static node& convert_to_node(const T& rhs, shared_memory_holder pMemory); 99 | 100 | private: 101 | bool m_isDefined; 102 | Mark m_mark; 103 | NodeType m_type; 104 | std::string m_tag; 105 | EmitterStyle m_style; 106 | 107 | // scalar 108 | std::string m_scalar; 109 | 110 | // sequence 111 | using node_seq = std::vector; 112 | node_seq m_sequence; 113 | 114 | mutable std::size_t m_seqSize; 115 | 116 | // map 117 | using node_map = std::vector>; 118 | node_map m_map; 119 | 120 | using kv_pair = std::pair; 121 | using kv_pairs = std::list; 122 | mutable kv_pairs m_undefinedPairs; 123 | }; 124 | } 125 | } 126 | 127 | #endif // VALUE_DETAIL_NODE_DATA_H_62B23520_7C8E_11DE_8A39_0800200C9A66 128 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: Google 4 | AccessModifierOffset: -4 5 | AlignAfterOpenBracket: Align 6 | AlignConsecutiveMacros: None 7 | AlignConsecutiveAssignments: None 8 | AlignConsecutiveDeclarations: None 9 | AlignEscapedNewlines: Left 10 | AlignOperands: DontAlign 11 | AlignTrailingComments: true 12 | AllowAllArgumentsOnNextLine: true 13 | AllowAllConstructorInitializersOnNextLine: true 14 | AllowAllParametersOfDeclarationOnNextLine: true 15 | AllowShortBlocksOnASingleLine: Empty 16 | AllowShortCaseLabelsOnASingleLine: true 17 | AllowShortEnumsOnASingleLine: true 18 | AllowShortFunctionsOnASingleLine: Empty 19 | AllowShortLambdasOnASingleLine: All 20 | AllowShortIfStatementsOnASingleLine: WithoutElse 21 | AllowShortLoopsOnASingleLine: true 22 | AlwaysBreakAfterDefinitionReturnType: None 23 | AlwaysBreakAfterReturnType: None 24 | AlwaysBreakBeforeMultilineStrings: false 25 | AlwaysBreakTemplateDeclarations: Yes 26 | BinPackArguments: true 27 | BinPackParameters: true 28 | BraceWrapping: 29 | AfterCaseLabel: false 30 | AfterClass: false 31 | AfterControlStatement: Never 32 | AfterEnum: false 33 | AfterFunction: false 34 | AfterNamespace: false 35 | AfterObjCDeclaration: false 36 | AfterStruct: false 37 | AfterUnion: false 38 | AfterExternBlock: false 39 | BeforeCatch: false 40 | BeforeElse: false 41 | IndentBraces: false 42 | SplitEmptyFunction: true 43 | SplitEmptyRecord: true 44 | SplitEmptyNamespace: true 45 | BreakBeforeBinaryOperators: None 46 | BreakBeforeBraces: Attach 47 | BreakBeforeInheritanceComma: false 48 | BreakInheritanceList: AfterColon 49 | BreakBeforeTernaryOperators: true 50 | BreakConstructorInitializers: AfterColon 51 | BreakStringLiterals: true 52 | ColumnLimit: 120 53 | CommentPragmas: '^ IWYU pragma:' 54 | CompactNamespaces: false 55 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 56 | ConstructorInitializerIndentWidth: 4 57 | ContinuationIndentWidth: 4 58 | Cpp11BracedListStyle: true 59 | DeriveLineEnding: true 60 | ExperimentalAutoDetectBinPacking: false 61 | FixNamespaceComments: true 62 | IncludeBlocks: Regroup 63 | IncludeCategories: 64 | - Regex: '^' 65 | Priority: 2 66 | SortPriority: 0 67 | - Regex: '^<.*\.h>' 68 | Priority: 1 69 | SortPriority: 0 70 | - Regex: '^<.*' 71 | Priority: 2 72 | SortPriority: 0 73 | - Regex: '.*' 74 | Priority: 3 75 | SortPriority: 0 76 | IncludeIsMainRegex: '([-_](test|unittest))?$' 77 | IncludeIsMainSourceRegex: '' 78 | IndentAccessModifiers: false 79 | IndentCaseLabels: true 80 | IndentGotoLabels: true 81 | IndentPPDirectives: None 82 | IndentWidth: 4 83 | IndentWrappedFunctionNames: false 84 | KeepEmptyLinesAtTheStartOfBlocks: false 85 | MaxEmptyLinesToKeep: 3 86 | NamespaceIndentation: None 87 | PenaltyBreakAssignment: 2 88 | PenaltyBreakBeforeFirstCallParameter: 1 89 | PenaltyBreakComment: 300 90 | PenaltyBreakFirstLessLess: 120 91 | PenaltyBreakString: 1000 92 | PenaltyBreakTemplateDeclaration: 10 93 | PenaltyExcessCharacter: 1000000 94 | PenaltyReturnTypeOnItsOwnLine: 200 95 | PointerAlignment: Left 96 | RawStringFormats: 97 | - Language: Cpp 98 | Delimiters: 99 | - cc 100 | - CC 101 | - cpp 102 | - Cpp 103 | - CPP 104 | - 'c++' 105 | - 'C++' 106 | CanonicalDelimiter: '' 107 | BasedOnStyle: google 108 | ReferenceAlignment: Left 109 | ReflowComments: true 110 | SortIncludes: Never 111 | SortUsingDeclarations: false 112 | SpaceAfterCStyleCast: false 113 | SpaceAfterLogicalNot: false 114 | SpaceAfterTemplateKeyword: false 115 | SpaceBeforeAssignmentOperators: true 116 | SpaceBeforeCpp11BracedList: false 117 | SpaceBeforeCtorInitializerColon: true 118 | SpaceBeforeInheritanceColon: true 119 | SpaceBeforeParens: ControlStatements 120 | SpaceBeforeRangeBasedForLoopColon: true 121 | SpaceInEmptyBlock: false 122 | SpaceInEmptyParentheses: false 123 | SpacesBeforeTrailingComments: 2 124 | SpacesInAngles: Never 125 | SpacesInConditionalStatement: false 126 | SpacesInContainerLiterals: false 127 | SpacesInCStyleCastParentheses: false 128 | SpacesInParentheses: false 129 | SpacesInSquareBrackets: false 130 | SpaceBeforeSquareBrackets: false 131 | Standard: Auto 132 | StatementMacros: 133 | - UPROEPRTY 134 | - UFUNCTION 135 | - UCLASS 136 | - USTRUCT 137 | - UENUM 138 | - UMETA 139 | TabWidth: 8 140 | UseCRLF: false 141 | UseTab: Never 142 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/node/node.h: -------------------------------------------------------------------------------- 1 | #ifndef NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | 14 | #include "emitterstyle.h" 15 | #include "mark.h" 16 | #include "node/detail/iterator_fwd.h" 17 | #include "node/ptr.h" 18 | #include "node/type.h" 19 | 20 | namespace YAML { 21 | namespace detail { 22 | class node; 23 | class node_data; 24 | struct iterator_value; 25 | } // namespace detail 26 | } // namespace YAML 27 | 28 | namespace YAML { 29 | class YAML_CPP_API Node { 30 | public: 31 | friend class NodeBuilder; 32 | friend class NodeEvents; 33 | friend struct detail::iterator_value; 34 | friend class detail::node; 35 | friend class detail::node_data; 36 | template 37 | friend class detail::iterator_base; 38 | template 39 | friend struct as_if; 40 | 41 | using iterator = YAML::iterator; 42 | using const_iterator = YAML::const_iterator; 43 | 44 | Node(); 45 | explicit Node(NodeType type); 46 | template 47 | explicit Node(const T& rhs); 48 | explicit Node(const detail::iterator_value& rhs); 49 | Node(const Node& rhs); 50 | ~Node(); 51 | 52 | YAML::Mark Mark() const; 53 | NodeType Type() const; 54 | bool IsDefined() const; 55 | bool IsNull() const { return Type() == NodeType::Null; } 56 | bool IsScalar() const { return Type() == NodeType::Scalar; } 57 | bool IsSequence() const { return Type() == NodeType::Sequence; } 58 | bool IsMap() const { return Type() == NodeType::Map; } 59 | 60 | // bool conversions 61 | explicit operator bool() const { return IsDefined(); } 62 | bool operator!() const { return !IsDefined(); } 63 | 64 | // access 65 | template 66 | T as() const; 67 | template 68 | T as(const S& fallback) const; 69 | const std::string& Scalar() const; 70 | 71 | const std::string& Tag() const; 72 | void SetTag(const std::string& tag); 73 | 74 | // style 75 | // WARNING: This API might change in future releases. 76 | EmitterStyle Style() const; 77 | void SetStyle(EmitterStyle style); 78 | 79 | // assignment 80 | bool is(const Node& rhs) const; 81 | template 82 | Node& operator=(const T& rhs); 83 | Node& operator=(const Node& rhs); 84 | void reset(const Node& rhs = Node()); 85 | 86 | // size/iterator 87 | std::size_t size() const; 88 | 89 | const_iterator begin() const; 90 | iterator begin(); 91 | 92 | const_iterator end() const; 93 | iterator end(); 94 | 95 | // sequence 96 | template 97 | void push_back(const T& rhs); 98 | void push_back(const Node& rhs); 99 | 100 | // indexing 101 | template 102 | const Node operator[](const Key& key) const; 103 | template 104 | Node operator[](const Key& key); 105 | template 106 | bool remove(const Key& key); 107 | 108 | const Node operator[](const Node& key) const; 109 | Node operator[](const Node& key); 110 | bool remove(const Node& key); 111 | 112 | // map 113 | template 114 | void force_insert(const Key& key, const Value& value); 115 | 116 | private: 117 | enum Zombie { ZombieNode }; 118 | explicit Node(Zombie); 119 | explicit Node(Zombie, const std::string&); 120 | explicit Node(detail::node& node, detail::shared_memory_holder pMemory); 121 | 122 | void EnsureNodeExists() const; 123 | 124 | template 125 | void Assign(const T& rhs); 126 | void Assign(const char* rhs); 127 | void Assign(char* rhs); 128 | 129 | void AssignData(const Node& rhs); 130 | void AssignNode(const Node& rhs); 131 | 132 | private: 133 | bool m_isValid; 134 | // String representation of invalid key, if the node is invalid. 135 | std::string m_invalidKey; 136 | mutable detail::shared_memory_holder m_pMemory; 137 | mutable detail::node* m_pNode; 138 | }; 139 | 140 | YAML_CPP_API bool operator==(const Node& lhs, const Node& rhs); 141 | 142 | YAML_CPP_API Node Clone(const Node& node); 143 | 144 | template 145 | struct convert; 146 | } 147 | 148 | #endif // NODE_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 149 | -------------------------------------------------------------------------------- /Source/UnrealYAML/Public/Parsing.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CoreMinimal.h" 4 | #include "Node.h" 5 | #include "Parsing.generated.h" 6 | 7 | 8 | DECLARE_LOG_CATEGORY_EXTERN(LogYamlParsing, Log, All) 9 | 10 | 11 | UCLASS(BlueprintType) 12 | class UNREALYAML_API UYamlParsing final : public UBlueprintFunctionLibrary { 13 | GENERATED_BODY() 14 | 15 | template 16 | friend bool ParseNodeIntoStruct(const FYamlNode&, T&); 17 | 18 | // Some conversion are defined in UnrealTypes.h. But FProperty does not provide a way to retrieve the Type, except as 19 | // an FString. This provides a list of all Types (as String) that can be directly converted via those conversion instead 20 | // of the Parsing all Fields further (basically a shortcut with neater results). This is only used to determine *if* an 21 | // FProperty can be converted directly, the if-else chain to check what type it actually is, is in ParseNativeType itself. 22 | const static TArray NativeTypes; 23 | 24 | public: 25 | // Parsing of Strings/Files into Nodes ----------------------------------------------------------------------------- 26 | /** Parses a String into an Yaml-Node. 27 | * 28 | * @returns If the Parsing was successful */ 29 | UFUNCTION(BlueprintCallable, Category="YAML") 30 | static bool ParseYaml(const FString String, FYamlNode& Out); 31 | 32 | /** Opens a Document and Parses the Contents into a Yaml Structure. 33 | * 34 | * @returns If the File Exists and the Parsing was successful */ 35 | UFUNCTION(BlueprintCallable, Category="YAML") 36 | static bool LoadYamlFromFile(const FString Path, FYamlNode& Out); 37 | 38 | /** Writes the Contents of a YAML-Node to an File. 39 | * This will overwrite the existing File if it exists! */ 40 | UFUNCTION(BlueprintCallable, Category="YAML") 41 | static void WriteYamlToFile(const FString Path, FYamlNode Node); 42 | 43 | 44 | // Parsing into Struct --------------------------------------------------------------------------------------------- 45 | 46 | /** Parse the given Node into the instance of the given Struct. The function will recursively iterate over all 47 | * Properties in the Struct and try to parse the contents of the corresponding Node-Entry into the Field of the Struct. 48 | * If there is no corresponding Field in the Node, the entry will be skipped. 49 | * 50 | * If you use a C++ USTRUCT, all Properties that you want parsed must be a UPROPERTY for the UHT 51 | * to register them. For easier c++ access, use the global ParseNodeIntoStruct function 52 | * 53 | * NOTE: Key-Comparison is case insensitive! 54 | * 55 | * @param Node The Node we want to Parse 56 | * @param Struct An instance of the Struct we want to parse into 57 | * @return Whether all Fields of the Struct were successfully parsed. 58 | */ 59 | UFUNCTION(BlueprintCallable, CustomThunk, DisplayName="Parse Node into Struct", Category="YAML", 60 | meta=(CustomStructureParam="Struct")) 61 | static bool ParseIntoStruct_BP(const FYamlNode& Node, const int32& Struct) { 62 | checkNoEntry() 63 | return false; 64 | } 65 | 66 | // Custom Thunk for ParseIntoStruct_BP 67 | DECLARE_FUNCTION(execParseIntoStruct_BP) { 68 | P_GET_STRUCT_REF(FYamlNode, Node) 69 | 70 | // Steps into the stack, walking to the next Object in it 71 | Stack.Step(Stack.Object, nullptr); 72 | 73 | // Grab the last property found when we walked the stack. This does not contains the property value, only its type information 74 | const FStructProperty* StructProperty = CastField(Stack.MostRecentProperty); 75 | if (!StructProperty) 76 | UE_LOG(LogYamlParsing, Error, TEXT("ParseIntoStruct did not receive an Struct Property: '%s'"), 77 | *Stack.MostRecentProperty->GetName()) 78 | 79 | // Grab the base address where the struct actually stores its data. This is where the property value is truly stored 80 | void* StructPtr = Stack.MostRecentPropertyAddress; 81 | 82 | P_FINISH 83 | 84 | if (StructProperty) { 85 | *static_cast(RESULT_PARAM) = ParseIntoStruct(Node, StructProperty->Struct, StructPtr); 86 | } 87 | } 88 | 89 | private: 90 | // Parses a Node into a Single Property. Can be a FStructProperty itself (recursion!) 91 | static bool ParseIntoProperty(const FYamlNode& Node, const FProperty& Property, void* PropertyValue); 92 | 93 | // Parses a Node into a Single UObject. Calls ParseIntoProperty on all Fields 94 | static bool ParseIntoObject(const FYamlNode& Node, const UClass* Object, void* ObjectValue); 95 | 96 | // Parses a Node into a Single Struct. Calls ParseIntoProperty on all Fields 97 | static bool ParseIntoStruct(const FYamlNode& Node, const UScriptStruct* Struct, void* StructValue); 98 | 99 | // Parses a Node via some predefined conversions in UnrealTypes.h via a switch case (see NativeTypes). 100 | static bool ParseIntoNativeType(const FYamlNode& Node, const UScriptStruct* Struct, void* StructValue); 101 | }; 102 | 103 | 104 | /** C++ Wrapper for UYamlParsing::ParseIntoStruct */ 105 | template 106 | FORCENOINLINE bool ParseNodeIntoStruct(const FYamlNode& Node, T& StructIn) { 107 | return UYamlParsing::ParseIntoStruct(Node, StructIn.StaticStruct(), &StructIn); 108 | } 109 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/node/detail/node_iterator.h: -------------------------------------------------------------------------------- 1 | #ifndef VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | 11 | #include "node/ptr.h" 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | namespace YAML { 20 | namespace detail { 21 | enum class iterator_type {NoneType, Sequence, Map}; 22 | 23 | template 24 | struct node_iterator_value : public std::pair { 25 | using kv = std::pair; 26 | 27 | node_iterator_value() : kv(), pNode(nullptr) {} 28 | explicit node_iterator_value(V& rhs) : kv(), pNode(&rhs) {} 29 | explicit node_iterator_value(V& key, V& value) : kv(&key, &value), pNode(nullptr) {} 30 | 31 | V& operator*() const { return *pNode; } 32 | V& operator->() const { return *pNode; } 33 | 34 | V* pNode; 35 | }; 36 | 37 | using node_seq = std::vector; 38 | using node_map = std::vector>; 39 | 40 | template 41 | struct node_iterator_type { 42 | using seq = node_seq::iterator; 43 | using map = node_map::iterator; 44 | }; 45 | 46 | template 47 | struct node_iterator_type { 48 | using seq = node_seq::const_iterator; 49 | using map = node_map::const_iterator; 50 | }; 51 | 52 | template 53 | class node_iterator_base { 54 | private: 55 | struct enabler {}; 56 | 57 | struct proxy { 58 | explicit proxy(const node_iterator_value& x) : m_ref(x) {} 59 | node_iterator_value* operator->() { return std::addressof(m_ref); } 60 | operator node_iterator_value*() { return std::addressof(m_ref); } 61 | 62 | node_iterator_value m_ref; 63 | }; 64 | 65 | public: 66 | using iterator_category = std::forward_iterator_tag; 67 | using value_type = node_iterator_value; 68 | using difference_type = std::ptrdiff_t; 69 | using pointer = node_iterator_value*; 70 | using reference = node_iterator_value; 71 | using SeqIter = typename node_iterator_type::seq; 72 | using MapIter = typename node_iterator_type::map; 73 | 74 | node_iterator_base() 75 | : m_type(iterator_type::NoneType), m_seqIt(), m_mapIt(), m_mapEnd() {} 76 | explicit node_iterator_base(SeqIter seqIt) 77 | : m_type(iterator_type::Sequence), 78 | m_seqIt(seqIt), 79 | m_mapIt(), 80 | m_mapEnd() {} 81 | explicit node_iterator_base(MapIter mapIt, MapIter mapEnd) 82 | : m_type(iterator_type::Map), 83 | m_seqIt(), 84 | m_mapIt(mapIt), 85 | m_mapEnd(mapEnd) { 86 | m_mapIt = increment_until_defined(m_mapIt); 87 | } 88 | 89 | template 90 | node_iterator_base(const node_iterator_base& rhs, 91 | typename std::enable_if::value, 92 | enabler>::type = enabler()) 93 | : m_type(rhs.m_type), 94 | m_seqIt(rhs.m_seqIt), 95 | m_mapIt(rhs.m_mapIt), 96 | m_mapEnd(rhs.m_mapEnd) {} 97 | 98 | template 99 | friend class node_iterator_base; 100 | 101 | template 102 | bool operator==(const node_iterator_base& rhs) const { 103 | if (m_type != rhs.m_type) 104 | return false; 105 | 106 | switch (m_type) { 107 | case iterator_type::NoneType: 108 | return true; 109 | case iterator_type::Sequence: 110 | return m_seqIt == rhs.m_seqIt; 111 | case iterator_type::Map: 112 | return m_mapIt == rhs.m_mapIt; 113 | } 114 | return true; 115 | } 116 | 117 | template 118 | bool operator!=(const node_iterator_base& rhs) const { 119 | return !(*this == rhs); 120 | } 121 | 122 | node_iterator_base& operator++() { 123 | switch (m_type) { 124 | case iterator_type::NoneType: 125 | break; 126 | case iterator_type::Sequence: 127 | ++m_seqIt; 128 | break; 129 | case iterator_type::Map: 130 | ++m_mapIt; 131 | m_mapIt = increment_until_defined(m_mapIt); 132 | break; 133 | } 134 | return *this; 135 | } 136 | 137 | node_iterator_base operator++(int) { 138 | node_iterator_base iterator_pre(*this); 139 | ++(*this); 140 | return iterator_pre; 141 | } 142 | 143 | value_type operator*() const { 144 | switch (m_type) { 145 | case iterator_type::NoneType: 146 | return value_type(); 147 | case iterator_type::Sequence: 148 | return value_type(**m_seqIt); 149 | case iterator_type::Map: 150 | return value_type(*m_mapIt->first, *m_mapIt->second); 151 | } 152 | return value_type(); 153 | } 154 | 155 | proxy operator->() const { return proxy(**this); } 156 | 157 | MapIter increment_until_defined(MapIter it) { 158 | while (it != m_mapEnd && !is_defined(it)) 159 | ++it; 160 | return it; 161 | } 162 | 163 | bool is_defined(MapIter it) const { 164 | return it->first->is_defined() && it->second->is_defined(); 165 | } 166 | 167 | private: 168 | iterator_type m_type; 169 | 170 | SeqIter m_seqIt; 171 | MapIter m_mapIt, m_mapEnd; 172 | }; 173 | 174 | using node_iterator = node_iterator_base; 175 | using const_node_iterator = node_iterator_base; 176 | } 177 | } 178 | 179 | #endif // VALUE_DETAIL_NODE_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 180 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/scanner.h: -------------------------------------------------------------------------------- 1 | #ifndef SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "ptr_vector.h" 19 | #include "stream.h" 20 | #include "token.h" 21 | #include "mark.h" 22 | 23 | namespace YAML { 24 | class Node; 25 | class RegEx; 26 | 27 | /** 28 | * A scanner transforms a stream of characters into a stream of tokens. 29 | */ 30 | class Scanner { 31 | public: 32 | explicit Scanner(std::istream &in); 33 | ~Scanner(); 34 | 35 | /** Returns true if there are no more tokens to be read. */ 36 | bool empty(); 37 | 38 | /** Removes the next token in the queue. */ 39 | void pop(); 40 | 41 | /** Returns, but does not remove, the next token in the queue. */ 42 | Token &peek(); 43 | 44 | /** Returns the current mark in the input stream. */ 45 | Mark mark() const; 46 | 47 | private: 48 | struct IndentMarker { 49 | enum INDENT_TYPE { MAP, SEQ, NONE }; 50 | enum STATUS { VALID, INVALID, UNKNOWN }; 51 | IndentMarker(int column_, INDENT_TYPE type_) 52 | : column(column_), type(type_), status(VALID), pStartToken(nullptr) {} 53 | 54 | int column; 55 | INDENT_TYPE type; 56 | STATUS status; 57 | Token *pStartToken; 58 | }; 59 | 60 | enum FLOW_MARKER { FLOW_MAP, FLOW_SEQ }; 61 | 62 | private: 63 | // scanning 64 | 65 | /** 66 | * Scans until there's a valid token at the front of the queue, or the queue 67 | * is empty. The state can be checked by {@link #empty}, and the next token 68 | * retrieved by {@link #peek}. 69 | */ 70 | void EnsureTokensInQueue(); 71 | 72 | /** 73 | * The main scanning function; this method branches out to scan whatever the 74 | * next token should be. 75 | */ 76 | void ScanNextToken(); 77 | 78 | /** Eats the input stream until it reaches the next token-like thing. */ 79 | void ScanToNextToken(); 80 | 81 | /** Sets the initial conditions for starting a stream. */ 82 | void StartStream(); 83 | 84 | /** Closes out the stream, finish up, etc. */ 85 | void EndStream(); 86 | 87 | Token *PushToken(Token::TYPE type); 88 | 89 | bool InFlowContext() const { return !m_flows.empty(); } 90 | bool InBlockContext() const { return m_flows.empty(); } 91 | std::size_t GetFlowLevel() const { return m_flows.size(); } 92 | 93 | Token::TYPE GetStartTokenFor(IndentMarker::INDENT_TYPE type) const; 94 | 95 | /** 96 | * Pushes an indentation onto the stack, and enqueues the proper token 97 | * (sequence start or mapping start). 98 | * 99 | * @return the indent marker it generates (if any). 100 | */ 101 | IndentMarker *PushIndentTo(int column, IndentMarker::INDENT_TYPE type); 102 | 103 | /** 104 | * Pops indentations off the stack until it reaches the current indentation 105 | * level, and enqueues the proper token each time. Then pops all invalid 106 | * indentations off. 107 | */ 108 | void PopIndentToHere(); 109 | 110 | /** 111 | * Pops all indentations (except for the base empty one) off the stack, and 112 | * enqueues the proper token each time. 113 | */ 114 | void PopAllIndents(); 115 | 116 | /** Pops a single indent, pushing the proper token. */ 117 | void PopIndent(); 118 | int GetTopIndent() const; 119 | 120 | // checking input 121 | bool CanInsertPotentialSimpleKey() const; 122 | bool ExistsActiveSimpleKey() const; 123 | void InsertPotentialSimpleKey(); 124 | void InvalidateSimpleKey(); 125 | bool VerifySimpleKey(); 126 | void PopAllSimpleKeys(); 127 | 128 | /** 129 | * Throws a ParserException with the current token location (if available), 130 | * and does not parse any more tokens. 131 | */ 132 | void ThrowParserException(const std::string &msg) const; 133 | 134 | bool IsWhitespaceToBeEaten(char ch); 135 | 136 | /** 137 | * Returns the appropriate regex to check if the next token is a value token. 138 | */ 139 | const RegEx &GetValueRegex() const; 140 | 141 | struct SimpleKey { 142 | SimpleKey(const Mark &mark_, std::size_t flowLevel_); 143 | 144 | void Validate(); 145 | void Invalidate(); 146 | 147 | Mark mark; 148 | std::size_t flowLevel; 149 | IndentMarker *pIndent; 150 | Token *pMapStart, *pKey; 151 | }; 152 | 153 | // and the tokens 154 | void ScanDirective(); 155 | void ScanDocStart(); 156 | void ScanDocEnd(); 157 | void ScanBlockSeqStart(); 158 | void ScanBlockMapSTart(); 159 | void ScanBlockEnd(); 160 | void ScanBlockEntry(); 161 | void ScanFlowStart(); 162 | void ScanFlowEnd(); 163 | void ScanFlowEntry(); 164 | void ScanKey(); 165 | void ScanValue(); 166 | void ScanAnchorOrAlias(); 167 | void ScanTag(); 168 | void ScanPlainScalar(); 169 | void ScanQuotedScalar(); 170 | void ScanBlockScalar(); 171 | 172 | private: 173 | // the stream 174 | Stream INPUT; 175 | 176 | // the output (tokens) 177 | std::queue m_tokens; 178 | 179 | // state info 180 | bool m_startedStream, m_endedStream; 181 | bool m_simpleKeyAllowed; 182 | bool m_canBeJSONFlow; 183 | std::stack m_simpleKeys; 184 | std::stack m_indents; 185 | ptr_vector m_indentRefs; // for "garbage collection" 186 | std::stack m_flows; 187 | }; 188 | } 189 | 190 | #endif // SCANNER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 191 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/regeximpl.h: -------------------------------------------------------------------------------- 1 | #ifndef REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "stream.h" 11 | #include "streamcharsource.h" 12 | #include "stringsource.h" 13 | 14 | namespace YAML { 15 | // query matches 16 | inline bool RegEx::Matches(char ch) const { 17 | std::string str; 18 | str += ch; 19 | return Matches(str); 20 | } 21 | 22 | inline bool RegEx::Matches(const std::string& str) const { 23 | return Match(str) >= 0; 24 | } 25 | 26 | inline bool RegEx::Matches(const Stream& in) const { return Match(in) >= 0; } 27 | 28 | template 29 | inline bool RegEx::Matches(const Source& source) const { 30 | return Match(source) >= 0; 31 | } 32 | 33 | // Match 34 | // . Matches the given string against this regular expression. 35 | // . Returns the number of characters matched. 36 | // . Returns -1 if no characters were matched (the reason for 37 | // not returning zero is that we may have an empty regex 38 | // which is ALWAYS successful at matching zero characters). 39 | // . REMEMBER that we only match from the start of the buffer! 40 | inline int RegEx::Match(const std::string& str) const { 41 | StringCharSource source(str.c_str(), str.size()); 42 | return Match(source); 43 | } 44 | 45 | inline int RegEx::Match(const Stream& in) const { 46 | StreamCharSource source(in); 47 | return Match(source); 48 | } 49 | 50 | template 51 | inline bool RegEx::IsValidSource(const Source& source) const { 52 | return source; 53 | } 54 | 55 | template <> 56 | inline bool RegEx::IsValidSource( 57 | const StringCharSource& source) const { 58 | switch (m_op) { 59 | case REGEX_MATCH: 60 | case REGEX_RANGE: 61 | return source; 62 | default: 63 | return true; 64 | } 65 | } 66 | 67 | template 68 | inline int RegEx::Match(const Source& source) const { 69 | return IsValidSource(source) ? MatchUnchecked(source) : -1; 70 | } 71 | 72 | template 73 | inline int RegEx::MatchUnchecked(const Source& source) const { 74 | switch (m_op) { 75 | case REGEX_EMPTY: 76 | return MatchOpEmpty(source); 77 | case REGEX_MATCH: 78 | return MatchOpMatch(source); 79 | case REGEX_RANGE: 80 | return MatchOpRange(source); 81 | case REGEX_OR: 82 | return MatchOpOr(source); 83 | case REGEX_AND: 84 | return MatchOpAnd(source); 85 | case REGEX_NOT: 86 | return MatchOpNot(source); 87 | case REGEX_SEQ: 88 | return MatchOpSeq(source); 89 | } 90 | 91 | return -1; 92 | } 93 | 94 | ////////////////////////////////////////////////////////////////////////////// 95 | // Operators 96 | // Note: the convention MatchOp* is that we can assume 97 | // IsSourceValid(source). 98 | // So we do all our checks *before* we call these functions 99 | 100 | // EmptyOperator 101 | template 102 | inline int RegEx::MatchOpEmpty(const Source& source) const { 103 | return source[0] == Stream::eof() ? 0 : -1; 104 | } 105 | 106 | template <> 107 | inline int RegEx::MatchOpEmpty( 108 | const StringCharSource& source) const { 109 | return !source ? 0 : -1; // the empty regex only is successful on the empty 110 | // string 111 | } 112 | 113 | // MatchOperator 114 | template 115 | inline int RegEx::MatchOpMatch(const Source& source) const { 116 | if (source[0] != m_a) 117 | return -1; 118 | return 1; 119 | } 120 | 121 | // RangeOperator 122 | template 123 | inline int RegEx::MatchOpRange(const Source& source) const { 124 | if (m_a > source[0] || m_z < source[0]) 125 | return -1; 126 | return 1; 127 | } 128 | 129 | // OrOperator 130 | template 131 | inline int RegEx::MatchOpOr(const Source& source) const { 132 | for (const RegEx& param : m_params) { 133 | int n = param.MatchUnchecked(source); 134 | if (n >= 0) 135 | return n; 136 | } 137 | return -1; 138 | } 139 | 140 | // AndOperator 141 | // Note: 'AND' is a little funny, since we may be required to match things 142 | // of different lengths. If we find a match, we return the length of 143 | // the FIRST entry on the list. 144 | template 145 | inline int RegEx::MatchOpAnd(const Source& source) const { 146 | int first = -1; 147 | for (std::size_t i = 0; i < m_params.size(); i++) { 148 | int n = m_params[i].MatchUnchecked(source); 149 | if (n == -1) 150 | return -1; 151 | if (i == 0) 152 | first = n; 153 | } 154 | return first; 155 | } 156 | 157 | // NotOperator 158 | template 159 | inline int RegEx::MatchOpNot(const Source& source) const { 160 | if (m_params.empty()) 161 | return -1; 162 | if (m_params[0].MatchUnchecked(source) >= 0) 163 | return -1; 164 | return 1; 165 | } 166 | 167 | // SeqOperator 168 | template 169 | inline int RegEx::MatchOpSeq(const Source& source) const { 170 | int offset = 0; 171 | for (const RegEx& param : m_params) { 172 | int n = param.Match(source + offset); // note Match, not 173 | // MatchUnchecked because we 174 | // need to check validity after 175 | // the offset 176 | if (n == -1) 177 | return -1; 178 | offset += n; 179 | } 180 | 181 | return offset; 182 | } 183 | } // namespace YAML 184 | 185 | #endif // REGEXIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 186 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/node/detail/node.h: -------------------------------------------------------------------------------- 1 | #ifndef NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | 11 | #include "emitterstyle.h" 12 | #include "node/detail/node_ref.h" 13 | #include "node/ptr.h" 14 | #include "node/type.h" 15 | #include 16 | #include 17 | 18 | namespace YAML { 19 | namespace detail { 20 | class node { 21 | private: 22 | struct less { 23 | bool operator ()(const node* l, const node* r) const {return l->m_index < r->m_index;} 24 | }; 25 | 26 | public: 27 | node() : m_pRef(new node_ref), m_dependencies{}, m_index{} {} 28 | node(const node&) = delete; 29 | node& operator=(const node&) = delete; 30 | 31 | bool is(const node& rhs) const { return m_pRef == rhs.m_pRef; } 32 | const node_ref* ref() const { return m_pRef.get(); } 33 | 34 | bool is_defined() const { return m_pRef->is_defined(); } 35 | const Mark& mark() const { return m_pRef->mark(); } 36 | NodeType type() const { return m_pRef->type(); } 37 | 38 | const std::string& scalar() const { return m_pRef->scalar(); } 39 | const std::string& tag() const { return m_pRef->tag(); } 40 | EmitterStyle style() const { return m_pRef->style(); } 41 | 42 | template 43 | bool equals(const T& rhs, shared_memory_holder pMemory); 44 | bool equals(const char* rhs, shared_memory_holder pMemory); 45 | 46 | void mark_defined() { 47 | if (is_defined()) 48 | return; 49 | 50 | m_pRef->mark_defined(); 51 | for (node* dependency : m_dependencies) 52 | dependency->mark_defined(); 53 | m_dependencies.clear(); 54 | } 55 | 56 | void add_dependency(node& rhs) { 57 | if (is_defined()) 58 | rhs.mark_defined(); 59 | else 60 | m_dependencies.insert(&rhs); 61 | } 62 | 63 | void set_ref(const node& rhs) { 64 | if (rhs.is_defined()) 65 | mark_defined(); 66 | m_pRef = rhs.m_pRef; 67 | } 68 | void set_data(const node& rhs) { 69 | if (rhs.is_defined()) 70 | mark_defined(); 71 | m_pRef->set_data(*rhs.m_pRef); 72 | } 73 | 74 | void set_mark(const Mark& mark) { m_pRef->set_mark(mark); } 75 | 76 | void set_type(NodeType type) { 77 | if (type != NodeType::Undefined) 78 | mark_defined(); 79 | m_pRef->set_type(type); 80 | } 81 | void set_null() { 82 | mark_defined(); 83 | m_pRef->set_null(); 84 | } 85 | void set_scalar(const std::string& scalar) { 86 | mark_defined(); 87 | m_pRef->set_scalar(scalar); 88 | } 89 | void set_tag(const std::string& tag) { 90 | mark_defined(); 91 | m_pRef->set_tag(tag); 92 | } 93 | 94 | // style 95 | void set_style(EmitterStyle style) { 96 | mark_defined(); 97 | m_pRef->set_style(style); 98 | } 99 | 100 | // size/iterator 101 | std::size_t size() const { return m_pRef->size(); } 102 | 103 | const_node_iterator begin() const { 104 | return static_cast(*m_pRef).begin(); 105 | } 106 | node_iterator begin() { return m_pRef->begin(); } 107 | 108 | const_node_iterator end() const { 109 | return static_cast(*m_pRef).end(); 110 | } 111 | node_iterator end() { return m_pRef->end(); } 112 | 113 | // sequence 114 | void push_back(node& input, shared_memory_holder pMemory) { 115 | m_pRef->push_back(input, pMemory); 116 | input.add_dependency(*this); 117 | m_index = m_amount.fetch_add(1); 118 | } 119 | void insert(node& key, node& value, shared_memory_holder pMemory) { 120 | m_pRef->insert(key, value, pMemory); 121 | key.add_dependency(*this); 122 | value.add_dependency(*this); 123 | } 124 | 125 | // indexing 126 | template 127 | node* get(const Key& key, shared_memory_holder pMemory) const { 128 | // NOTE: this returns a non-const node so that the top-level Node can wrap 129 | // it, and returns a pointer so that it can be nullptr (if there is no such 130 | // key). 131 | return static_cast(*m_pRef).get(key, pMemory); 132 | } 133 | template 134 | node& get(const Key& key, shared_memory_holder pMemory) { 135 | node& value = m_pRef->get(key, pMemory); 136 | value.add_dependency(*this); 137 | return value; 138 | } 139 | template 140 | bool remove(const Key& key, shared_memory_holder pMemory) { 141 | return m_pRef->remove(key, pMemory); 142 | } 143 | 144 | node* get(node& key, shared_memory_holder pMemory) const { 145 | // NOTE: this returns a non-const node so that the top-level Node can wrap 146 | // it, and returns a pointer so that it can be nullptr (if there is no such 147 | // key). 148 | return static_cast(*m_pRef).get(key, pMemory); 149 | } 150 | node& get(node& key, shared_memory_holder pMemory) { 151 | node& value = m_pRef->get(key, pMemory); 152 | key.add_dependency(*this); 153 | value.add_dependency(*this); 154 | return value; 155 | } 156 | bool remove(node& key, shared_memory_holder pMemory) { 157 | return m_pRef->remove(key, pMemory); 158 | } 159 | 160 | // map 161 | template 162 | void force_insert(const Key& key, const Value& value, 163 | shared_memory_holder pMemory) { 164 | m_pRef->force_insert(key, value, pMemory); 165 | } 166 | 167 | private: 168 | shared_node_ref m_pRef; 169 | using nodes = std::set; 170 | nodes m_dependencies; 171 | size_t m_index; 172 | static YAML_CPP_API std::atomic m_amount; 173 | }; 174 | } // namespace detail 175 | } // namespace YAML 176 | 177 | #endif // NODE_DETAIL_NODE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 178 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/contrib/graphbuilder.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "mark.h" 11 | #include 12 | 13 | namespace YAML { 14 | class Parser; 15 | 16 | // GraphBuilderInterface 17 | // . Abstraction of node creation 18 | // . pParentNode is always nullptr or the return value of one of the NewXXX() 19 | // functions. 20 | class GraphBuilderInterface { 21 | public: 22 | virtual ~GraphBuilderInterface() = 0; 23 | 24 | // Create and return a new node with a null value. 25 | virtual void *NewNull(const Mark &mark, void *pParentNode) = 0; 26 | 27 | // Create and return a new node with the given tag and value. 28 | virtual void *NewScalar(const Mark &mark, const std::string &tag, 29 | void *pParentNode, const std::string &value) = 0; 30 | 31 | // Create and return a new sequence node 32 | virtual void *NewSequence(const Mark &mark, const std::string &tag, 33 | void *pParentNode) = 0; 34 | 35 | // Add pNode to pSequence. pNode was created with one of the NewXxx() 36 | // functions and pSequence with NewSequence(). 37 | virtual void AppendToSequence(void *pSequence, void *pNode) = 0; 38 | 39 | // Note that no moew entries will be added to pSequence 40 | virtual void SequenceComplete(void *pSequence) { (void)pSequence; } 41 | 42 | // Create and return a new map node 43 | virtual void *NewMap(const Mark &mark, const std::string &tag, 44 | void *pParentNode) = 0; 45 | 46 | // Add the pKeyNode => pValueNode mapping to pMap. pKeyNode and pValueNode 47 | // were created with one of the NewXxx() methods and pMap with NewMap(). 48 | virtual void AssignInMap(void *pMap, void *pKeyNode, void *pValueNode) = 0; 49 | 50 | // Note that no more assignments will be made in pMap 51 | virtual void MapComplete(void *pMap) { (void)pMap; } 52 | 53 | // Return the node that should be used in place of an alias referencing 54 | // pNode (pNode by default) 55 | virtual void *AnchorReference(const Mark &mark, void *pNode) { 56 | (void)mark; 57 | return pNode; 58 | } 59 | }; 60 | 61 | // Typesafe wrapper for GraphBuilderInterface. Assumes that Impl defines 62 | // Node, Sequence, and Map types. Sequence and Map must derive from Node 63 | // (unless Node is defined as void). Impl must also implement function with 64 | // all of the same names as the virtual functions in GraphBuilderInterface 65 | // -- including the ones with default implementations -- but with the 66 | // prototypes changed to accept an explicit Node*, Sequence*, or Map* where 67 | // appropriate. 68 | template 69 | class GraphBuilder : public GraphBuilderInterface { 70 | public: 71 | typedef typename Impl::Node Node; 72 | typedef typename Impl::Sequence Sequence; 73 | typedef typename Impl::Map Map; 74 | 75 | GraphBuilder(Impl &impl) : m_impl(impl) { 76 | Map *pMap = nullptr; 77 | Sequence *pSeq = nullptr; 78 | Node *pNode = nullptr; 79 | 80 | // Type consistency checks 81 | pNode = pMap; 82 | pNode = pSeq; 83 | } 84 | 85 | GraphBuilderInterface &AsBuilderInterface() { return *this; } 86 | 87 | virtual void *NewNull(const Mark &mark, void *pParentNode) { 88 | return CheckType(m_impl.NewNull(mark, AsNode(pParentNode))); 89 | } 90 | 91 | virtual void *NewScalar(const Mark &mark, const std::string &tag, 92 | void *pParentNode, const std::string &value) { 93 | return CheckType( 94 | m_impl.NewScalar(mark, tag, AsNode(pParentNode), value)); 95 | } 96 | 97 | virtual void *NewSequence(const Mark &mark, const std::string &tag, 98 | void *pParentNode) { 99 | return CheckType( 100 | m_impl.NewSequence(mark, tag, AsNode(pParentNode))); 101 | } 102 | virtual void AppendToSequence(void *pSequence, void *pNode) { 103 | m_impl.AppendToSequence(AsSequence(pSequence), AsNode(pNode)); 104 | } 105 | virtual void SequenceComplete(void *pSequence) { 106 | m_impl.SequenceComplete(AsSequence(pSequence)); 107 | } 108 | 109 | virtual void *NewMap(const Mark &mark, const std::string &tag, 110 | void *pParentNode) { 111 | return CheckType(m_impl.NewMap(mark, tag, AsNode(pParentNode))); 112 | } 113 | virtual void AssignInMap(void *pMap, void *pKeyNode, void *pValueNode) { 114 | m_impl.AssignInMap(AsMap(pMap), AsNode(pKeyNode), AsNode(pValueNode)); 115 | } 116 | virtual void MapComplete(void *pMap) { m_impl.MapComplete(AsMap(pMap)); } 117 | 118 | virtual void *AnchorReference(const Mark &mark, void *pNode) { 119 | return CheckType(m_impl.AnchorReference(mark, AsNode(pNode))); 120 | } 121 | 122 | private: 123 | Impl &m_impl; 124 | 125 | // Static check for pointer to T 126 | template 127 | static T *CheckType(U *p) { 128 | return p; 129 | } 130 | 131 | static Node *AsNode(void *pNode) { return static_cast(pNode); } 132 | static Sequence *AsSequence(void *pSeq) { 133 | return static_cast(pSeq); 134 | } 135 | static Map *AsMap(void *pMap) { return static_cast(pMap); } 136 | }; 137 | 138 | void *BuildGraphOfNextDocument(Parser &parser, 139 | GraphBuilderInterface &graphBuilder); 140 | 141 | template 142 | typename Impl::Node *BuildGraphOfNextDocument(Parser &parser, Impl &impl) { 143 | GraphBuilder graphBuilder(impl); 144 | return static_cast( 145 | BuildGraphOfNextDocument(parser, graphBuilder)); 146 | } 147 | } 148 | 149 | #endif // GRAPHBUILDER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 150 | -------------------------------------------------------------------------------- /Source/UnrealYAML/Private/Parsing.cpp: -------------------------------------------------------------------------------- 1 | #include "Parsing.h" 2 | 3 | 4 | DEFINE_LOG_CATEGORY(LogYamlParsing) 5 | 6 | 7 | // Parsing into/from Files --------------------------------------------------------------------------------------------- 8 | bool UYamlParsing::ParseYaml(const FString String, FYamlNode& Out) { 9 | try { 10 | Out = FYamlNode(YAML::Load(TCHAR_TO_UTF8(*String))); 11 | return true; 12 | } catch (YAML::ParserException) { 13 | return false; 14 | } 15 | } 16 | 17 | bool UYamlParsing::LoadYamlFromFile(const FString Path, FYamlNode& Out) { 18 | FString Contents; 19 | if (FFileHelper::LoadFileToString(Contents, *Path)) { 20 | return ParseYaml(Contents, Out); 21 | } 22 | return false; 23 | } 24 | 25 | void UYamlParsing::WriteYamlToFile(const FString Path, const FYamlNode Node) { 26 | FFileHelper::SaveStringToFile(Node.GetContent(), *Path); 27 | } 28 | 29 | 30 | // Parsing into Structs ------------------------------------------------------------------------------------------------ 31 | const TArray UYamlParsing::NativeTypes = {"FString", "FText", "FVector", "FQuat", "FTransform", "FColor", 32 | "FLinearColor"}; 33 | 34 | bool UYamlParsing::ParseIntoProperty(const FYamlNode& Node, const FProperty& Property, void* PropertyValue) { 35 | UE_LOG(LogYamlParsing, Verbose, TEXT("Parsing Node into Property '%s' of type '%s'"), *Property.GetName(), 36 | *Property.GetCPPType()) 37 | 38 | // If we access an invalid sequence or map entry, we will get an Zombie Node, which is invalid 39 | if (!Node.IsDefined()) { 40 | return false; 41 | } 42 | 43 | if (const FNumericProperty* NumericProperty = CastField(&Property)) { 44 | if (NumericProperty->IsInteger()) { 45 | const auto Value = Node.AsOptional(); 46 | if (Value.IsSet()) { 47 | NumericProperty->SetIntPropertyValue(PropertyValue, Value.GetValue()); 48 | } 49 | } else { 50 | const auto Value = Node.AsOptional(); 51 | if (Value.IsSet()) { 52 | NumericProperty->SetFloatingPointPropertyValue(PropertyValue, Value.GetValue()); 53 | } 54 | } 55 | } else if (const FBoolProperty* BoolProperty = CastField(&Property)) { 56 | const auto Value = Node.AsOptional(); 57 | if (Value.IsSet()) { 58 | BoolProperty->SetPropertyValue(PropertyValue, Value.GetValue()); 59 | } 60 | } else if (const FStrProperty* StringProperty = CastField(&Property)) { 61 | const auto Value = Node.AsOptional(); 62 | if (Value.IsSet()) { 63 | *const_cast(&StringProperty->GetPropertyValue(PropertyValue)) = Value.GetValue(); 64 | } 65 | } else if (const FTextProperty* TextProperty = CastField(&Property)) { 66 | const auto Value = Node.AsOptional(); 67 | if (Value.IsSet()) { 68 | *const_cast(&TextProperty->GetPropertyValue(PropertyValue)) = Value.GetValue(); 69 | } 70 | } else if (const FEnumProperty* EnumProperty = CastField(&Property)) { 71 | const int64 Index = EnumProperty->GetEnum()->GetIndexByNameString(Node.As()); 72 | EnumProperty->GetUnderlyingProperty()->SetIntPropertyValue(PropertyValue, Index); 73 | } else if (const FArrayProperty* ArrayProperty = CastField(&Property)) { 74 | // We need the helper to get to the items of the array 75 | FScriptArrayHelper Helper(ArrayProperty, PropertyValue); 76 | Helper.AddValues(Node.Size()); 77 | 78 | bool ParsedAllProperties = true; 79 | for (int32 i = 0; i < Helper.Num(); ++i) { 80 | if (!ParseIntoProperty(Node[i], *ArrayProperty->Inner, Helper.GetRawPtr(i))) { 81 | ParsedAllProperties = false; 82 | } 83 | } 84 | 85 | return ParsedAllProperties; 86 | } else if (const FObjectProperty* ObjectProperty = CastField(&Property)) { 87 | return ParseIntoObject(Node, ObjectProperty->PropertyClass, PropertyValue); 88 | } else if (const FStructProperty* StructProperty = CastField(&Property)) { 89 | return ParseIntoStruct(Node, StructProperty->Struct, PropertyValue); 90 | } 91 | 92 | return true; 93 | } 94 | 95 | bool UYamlParsing::ParseIntoObject(const FYamlNode& Node, const UClass* Object, void* ObjectValue) { 96 | UE_LOG(LogYamlParsing, Verbose, TEXT("Parsing Node into Object '%s'"), *Object->GetName()) 97 | 98 | bool ParsedAllProperties = true; 99 | for (TFieldIterator It(Object); It; ++It) { 100 | FString Key = It->GetName(); 101 | if (!ParseIntoProperty(Node[Key], **It, It->ContainerPtrToValuePtr(ObjectValue))) { 102 | ParsedAllProperties = false; 103 | } 104 | } 105 | 106 | return ParsedAllProperties; 107 | } 108 | 109 | bool UYamlParsing::ParseIntoStruct(const FYamlNode& Node, const UScriptStruct* Struct, void* StructValue) { 110 | UE_LOG(LogYamlParsing, Verbose, TEXT("Parsing Node into Struct '%s'"), *Struct->GetName()) 111 | 112 | if (NativeTypes.Contains(Struct->GetStructCPPName())) { 113 | return ParseIntoNativeType(Node, Struct, StructValue); 114 | } 115 | 116 | bool ParsedAllProperties = true; 117 | for (TFieldIterator It(Struct); It; ++It) { 118 | FString Key = It->GetName(); 119 | if (!ParseIntoProperty(Node[Key], **It, It->ContainerPtrToValuePtr(StructValue))) { 120 | ParsedAllProperties = false; 121 | } 122 | } 123 | 124 | return ParsedAllProperties; 125 | } 126 | 127 | bool UYamlParsing::ParseIntoNativeType(const FYamlNode& Node, const UScriptStruct* Struct, void* StructValue) { 128 | const FString Type = Struct->GetStructCPPName(); 129 | 130 | if (Type == "FString") { 131 | *static_cast(StructValue) = Node.As(); 132 | } else if (Type == "FText") { 133 | *static_cast(StructValue) = Node.As(); 134 | } else if (Type == "FVector") { 135 | *static_cast(StructValue) = Node.As(); 136 | } else if (Type == "FQuat") { 137 | *static_cast(StructValue) = Node.As(); 138 | } else if (Type == "FTransform") { 139 | *static_cast(StructValue) = Node.As(); 140 | } else if (Type == "FColor") { 141 | *static_cast(StructValue) = Node.As(); 142 | } else if (Type == "FLinearColor") { 143 | *static_cast(StructValue) = Node.As(); 144 | } else { 145 | checkf(false, TEXT("No native type conversion for %s"), *Type) 146 | return false; 147 | } 148 | 149 | return true; 150 | } 151 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/exp.h: -------------------------------------------------------------------------------- 1 | #ifndef EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | #include "regex_yaml.h" 14 | #include "stream.h" 15 | 16 | namespace YAML { 17 | //////////////////////////////////////////////////////////////////////////////// 18 | // Here we store a bunch of expressions for matching different parts of the 19 | // file. 20 | 21 | namespace Exp { 22 | // misc 23 | inline const RegEx& Empty() { 24 | static const RegEx e; 25 | return e; 26 | } 27 | inline const RegEx& Space() { 28 | static const RegEx e = RegEx(' '); 29 | return e; 30 | } 31 | inline const RegEx& Tab() { 32 | static const RegEx e = RegEx('\t'); 33 | return e; 34 | } 35 | inline const RegEx& Blank() { 36 | static const RegEx e = Space() | Tab(); 37 | return e; 38 | } 39 | inline const RegEx& Break() { 40 | static const RegEx e = RegEx('\n') | RegEx("\r\n"); 41 | return e; 42 | } 43 | inline const RegEx& BlankOrBreak() { 44 | static const RegEx e = Blank() | Break(); 45 | return e; 46 | } 47 | inline const RegEx& Digit() { 48 | static const RegEx e = RegEx('0', '9'); 49 | return e; 50 | } 51 | inline const RegEx& Alpha() { 52 | static const RegEx e = RegEx('a', 'z') | RegEx('A', 'Z'); 53 | return e; 54 | } 55 | inline const RegEx& AlphaNumeric() { 56 | static const RegEx e = Alpha() | Digit(); 57 | return e; 58 | } 59 | inline const RegEx& Word() { 60 | static const RegEx e = AlphaNumeric() | RegEx('-'); 61 | return e; 62 | } 63 | inline const RegEx& Hex() { 64 | static const RegEx e = Digit() | RegEx('A', 'F') | RegEx('a', 'f'); 65 | return e; 66 | } 67 | // Valid Unicode code points that are not part of c-printable (YAML 1.2, sec. 68 | // 5.1) 69 | inline const RegEx& NotPrintable() { 70 | static const RegEx e = 71 | RegEx(0) | 72 | RegEx("\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x7F", REGEX_OR) | 73 | RegEx(0x0E, 0x1F) | 74 | (RegEx('\xC2') + (RegEx('\x80', '\x84') | RegEx('\x86', '\x9F'))); 75 | return e; 76 | } 77 | inline const RegEx& Utf8_ByteOrderMark() { 78 | static const RegEx e = RegEx("\xEF\xBB\xBF"); 79 | return e; 80 | } 81 | 82 | // actual tags 83 | 84 | inline const RegEx& DocStart() { 85 | static const RegEx e = RegEx("---") + (BlankOrBreak() | RegEx()); 86 | return e; 87 | } 88 | inline const RegEx& DocEnd() { 89 | static const RegEx e = RegEx("...") + (BlankOrBreak() | RegEx()); 90 | return e; 91 | } 92 | inline const RegEx& DocIndicator() { 93 | static const RegEx e = DocStart() | DocEnd(); 94 | return e; 95 | } 96 | inline const RegEx& BlockEntry() { 97 | static const RegEx e = RegEx('-') + (BlankOrBreak() | RegEx()); 98 | return e; 99 | } 100 | inline const RegEx& Key() { 101 | static const RegEx e = RegEx('?') + BlankOrBreak(); 102 | return e; 103 | } 104 | inline const RegEx& KeyInFlow() { 105 | static const RegEx e = RegEx('?') + BlankOrBreak(); 106 | return e; 107 | } 108 | inline const RegEx& Value() { 109 | static const RegEx e = RegEx(':') + (BlankOrBreak() | RegEx()); 110 | return e; 111 | } 112 | inline const RegEx& ValueInFlow() { 113 | static const RegEx e = RegEx(':') + (BlankOrBreak() | RegEx(",]}", REGEX_OR)); 114 | return e; 115 | } 116 | inline const RegEx& ValueInJSONFlow() { 117 | static const RegEx e = RegEx(':'); 118 | return e; 119 | } 120 | inline const RegEx Comment() { 121 | static const RegEx e = RegEx('#'); 122 | return e; 123 | } 124 | inline const RegEx& Anchor() { 125 | static const RegEx e = !(RegEx("[]{},", REGEX_OR) | BlankOrBreak()); 126 | return e; 127 | } 128 | inline const RegEx& AnchorEnd() { 129 | static const RegEx e = RegEx("?:,]}%@`", REGEX_OR) | BlankOrBreak(); 130 | return e; 131 | } 132 | inline const RegEx& URI() { 133 | static const RegEx e = Word() | RegEx("#;/?:@&=+$,_.!~*'()[]", REGEX_OR) | 134 | (RegEx('%') + Hex() + Hex()); 135 | return e; 136 | } 137 | inline const RegEx& Tag() { 138 | static const RegEx e = Word() | RegEx("#;/?:@&=+$_.~*'()", REGEX_OR) | 139 | (RegEx('%') + Hex() + Hex()); 140 | return e; 141 | } 142 | 143 | // Plain scalar rules: 144 | // . Cannot start with a blank. 145 | // . Can never start with any of , [ ] { } # & * ! | > \' \" % @ ` 146 | // . In the block context - ? : must be not be followed with a space. 147 | // . In the flow context ? is illegal and : and - must not be followed with a 148 | // space. 149 | inline const RegEx& PlainScalar() { 150 | static const RegEx e = 151 | !(BlankOrBreak() | RegEx(",[]{}#&*!|>\'\"%@`", REGEX_OR) | 152 | (RegEx("-?:", REGEX_OR) + (BlankOrBreak() | RegEx()))); 153 | return e; 154 | } 155 | inline const RegEx& PlainScalarInFlow() { 156 | static const RegEx e = 157 | !(BlankOrBreak() | RegEx("?,[]{}#&*!|>\'\"%@`", REGEX_OR) | 158 | (RegEx("-:", REGEX_OR) + (Blank() | RegEx()))); 159 | return e; 160 | } 161 | inline const RegEx& EndScalar() { 162 | static const RegEx e = RegEx(':') + (BlankOrBreak() | RegEx()); 163 | return e; 164 | } 165 | inline const RegEx& EndScalarInFlow() { 166 | static const RegEx e = 167 | (RegEx(':') + (BlankOrBreak() | RegEx() | RegEx(",]}", REGEX_OR))) | 168 | RegEx(",?[]{}", REGEX_OR); 169 | return e; 170 | } 171 | 172 | inline const RegEx& ScanScalarEndInFlow() { 173 | static const RegEx e = (EndScalarInFlow() | (BlankOrBreak() + Comment())); 174 | return e; 175 | } 176 | 177 | inline const RegEx& ScanScalarEnd() { 178 | static const RegEx e = EndScalar() | (BlankOrBreak() + Comment()); 179 | return e; 180 | } 181 | inline const RegEx& EscSingleQuote() { 182 | static const RegEx e = RegEx("\'\'"); 183 | return e; 184 | } 185 | inline const RegEx& EscBreak() { 186 | static const RegEx e = RegEx('\\') + Break(); 187 | return e; 188 | } 189 | 190 | inline const RegEx& ChompIndicator() { 191 | static const RegEx e = RegEx("+-", REGEX_OR); 192 | return e; 193 | } 194 | inline const RegEx& Chomp() { 195 | static const RegEx e = (ChompIndicator() + Digit()) | 196 | (Digit() + ChompIndicator()) | ChompIndicator() | 197 | Digit(); 198 | return e; 199 | } 200 | 201 | // and some functions 202 | std::string Escape(Stream& in); 203 | } // namespace Exp 204 | 205 | namespace Keys { 206 | const char Directive = '%'; 207 | const char FlowSeqStart = '['; 208 | const char FlowSeqEnd = ']'; 209 | const char FlowMapStart = '{'; 210 | const char FlowMapEnd = '}'; 211 | const char FlowEntry = ','; 212 | const char Alias = '*'; 213 | const char Anchor = '&'; 214 | const char Tag = '!'; 215 | const char LiteralScalar = '|'; 216 | const char FoldedScalar = '>'; 217 | const char VerbatimTagStart = '<'; 218 | const char VerbatimTagEnd = '>'; 219 | } // namespace Keys 220 | } // namespace YAML 221 | 222 | #endif // EXP_H_62B23520_7C8E_11DE_8A39_0800200C9A66 223 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/src/emitterstate.h: -------------------------------------------------------------------------------- 1 | #ifndef EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "setting.h" 11 | #include "emitterdef.h" 12 | #include "emittermanip.h" 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | namespace YAML { 21 | enum class FmtScope {Local, Global}; 22 | 23 | enum class GroupType {NoType, Seq, Map}; 24 | 25 | enum class FlowType {NoType, Flow, Block}; 26 | 27 | class EmitterState { 28 | public: 29 | EmitterState(); 30 | ~EmitterState(); 31 | 32 | // basic state checking 33 | bool good() const { return m_isGood; } 34 | const std::string GetLastError() const { return m_lastError; } 35 | void SetError(const std::string& error) { 36 | m_isGood = false; 37 | m_lastError = error; 38 | } 39 | 40 | // node handling 41 | void SetAnchor(); 42 | void SetAlias(); 43 | void SetTag(); 44 | void SetNonContent(); 45 | void SetLongKey(); 46 | void ForceFlow(); 47 | void StartedDoc(); 48 | void EndedDoc(); 49 | void StartedScalar(); 50 | void StartedGroup(GroupType type); 51 | void EndedGroup(GroupType type); 52 | 53 | EmitterNodeType NextGroupType(GroupType type) const; 54 | EmitterNodeType CurGroupNodeType() const; 55 | 56 | GroupType CurGroupType() const; 57 | FlowType CurGroupFlowType() const; 58 | std::size_t CurGroupIndent() const; 59 | std::size_t CurGroupChildCount() const; 60 | bool CurGroupLongKey() const; 61 | 62 | std::size_t LastIndent() const; 63 | std::size_t CurIndent() const { return m_curIndent; } 64 | bool HasAnchor() const { return m_hasAnchor; } 65 | bool HasAlias() const { return m_hasAlias; } 66 | bool HasTag() const { return m_hasTag; } 67 | bool HasBegunNode() const { 68 | return m_hasAnchor || m_hasTag || m_hasNonContent; 69 | } 70 | bool HasBegunContent() const { return m_hasAnchor || m_hasTag; } 71 | 72 | void ClearModifiedSettings(); 73 | void RestoreGlobalModifiedSettings(); 74 | 75 | // formatters 76 | void SetLocalValue(EmitterManip value); 77 | 78 | bool SetOutputCharset(EmitterManip value, FmtScope scope); 79 | EmitterManip GetOutputCharset() const { return m_charset.get(); } 80 | 81 | bool SetStringFormat(EmitterManip value, FmtScope scope); 82 | EmitterManip GetStringFormat() const { return m_strFmt.get(); } 83 | 84 | bool SetBoolFormat(EmitterManip value, FmtScope scope); 85 | EmitterManip GetBoolFormat() const { return m_boolFmt.get(); } 86 | 87 | bool SetBoolLengthFormat(EmitterManip value, FmtScope scope); 88 | EmitterManip GetBoolLengthFormat() const { return m_boolLengthFmt.get(); } 89 | 90 | bool SetBoolCaseFormat(EmitterManip value, FmtScope scope); 91 | EmitterManip GetBoolCaseFormat() const { return m_boolCaseFmt.get(); } 92 | 93 | bool SetNullFormat(EmitterManip value, FmtScope scope); 94 | EmitterManip GetNullFormat() const { return m_nullFmt.get(); } 95 | 96 | bool SetIntFormat(EmitterManip value, FmtScope scope); 97 | EmitterManip GetIntFormat() const { return m_intFmt.get(); } 98 | 99 | bool SetIndent(std::size_t value, FmtScope scope); 100 | std::size_t GetIndent() const { return m_indent.get(); } 101 | 102 | bool SetPreCommentIndent(std::size_t value, FmtScope scope); 103 | std::size_t GetPreCommentIndent() const { return m_preCommentIndent.get(); } 104 | bool SetPostCommentIndent(std::size_t value, FmtScope scope); 105 | std::size_t GetPostCommentIndent() const { return m_postCommentIndent.get(); } 106 | 107 | bool SetFlowType(GroupType groupType, EmitterManip value, 108 | FmtScope scope); 109 | EmitterManip GetFlowType(GroupType groupType) const; 110 | 111 | bool SetMapKeyFormat(EmitterManip value, FmtScope scope); 112 | EmitterManip GetMapKeyFormat() const { return m_mapKeyFmt.get(); } 113 | 114 | bool SetFloatPrecision(std::size_t value, FmtScope scope); 115 | std::size_t GetFloatPrecision() const { return m_floatPrecision.get(); } 116 | bool SetDoublePrecision(std::size_t value, FmtScope scope); 117 | std::size_t GetDoublePrecision() const { return m_doublePrecision.get(); } 118 | 119 | private: 120 | template 121 | void _Set(Setting& fmt, T value, FmtScope scope); 122 | 123 | void StartedNode(); 124 | 125 | private: 126 | // basic state ok? 127 | bool m_isGood; 128 | std::string m_lastError; 129 | 130 | // other state 131 | Setting m_charset; 132 | Setting m_strFmt; 133 | Setting m_boolFmt; 134 | Setting m_boolLengthFmt; 135 | Setting m_boolCaseFmt; 136 | Setting m_nullFmt; 137 | Setting m_intFmt; 138 | Setting m_indent; 139 | Setting m_preCommentIndent, m_postCommentIndent; 140 | Setting m_seqFmt; 141 | Setting m_mapFmt; 142 | Setting m_mapKeyFmt; 143 | Setting m_floatPrecision; 144 | Setting m_doublePrecision; 145 | 146 | SettingChanges m_modifiedSettings; 147 | SettingChanges m_globalModifiedSettings; 148 | 149 | struct Group { 150 | explicit Group(GroupType type_) 151 | : type(type_), 152 | flowType{}, 153 | indent(0), 154 | childCount(0), 155 | longKey(false), 156 | modifiedSettings{} {} 157 | 158 | GroupType type; 159 | FlowType flowType; 160 | std::size_t indent; 161 | std::size_t childCount; 162 | bool longKey; 163 | 164 | SettingChanges modifiedSettings; 165 | 166 | EmitterNodeType NodeType() const { 167 | if (type == GroupType::Seq) { 168 | if (flowType == FlowType::Flow) 169 | return EmitterNodeType::FlowSeq; 170 | else 171 | return EmitterNodeType::BlockSeq; 172 | } else { 173 | if (flowType == FlowType::Flow) 174 | return EmitterNodeType::FlowMap; 175 | else 176 | return EmitterNodeType::BlockMap; 177 | } 178 | } 179 | }; 180 | 181 | std::vector> m_groups; 182 | std::size_t m_curIndent; 183 | bool m_hasAnchor; 184 | bool m_hasAlias; 185 | bool m_hasTag; 186 | bool m_hasNonContent; 187 | std::size_t m_docCount; 188 | }; 189 | 190 | template 191 | void EmitterState::_Set(Setting& fmt, T value, FmtScope scope) { 192 | switch (scope) { 193 | case FmtScope::Local: 194 | m_modifiedSettings.push(fmt.set(value)); 195 | break; 196 | case FmtScope::Global: 197 | fmt.set(value); 198 | m_globalModifiedSettings.push( 199 | fmt.set(value)); // this pushes an identity set, so when we restore, 200 | // it restores to the value here, and not the previous one 201 | break; 202 | default: 203 | assert(false); 204 | } 205 | } 206 | } // namespace YAML 207 | 208 | #endif // EMITTERSTATE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 209 | -------------------------------------------------------------------------------- /Source/UnrealYAML/yaml-cpp/include/node/detail/impl.h: -------------------------------------------------------------------------------- 1 | #ifndef NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 | #define NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 3 | 4 | #if defined(_MSC_VER) || \ 5 | (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 | (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 7 | #pragma once 8 | #endif 9 | 10 | #include "node/detail/node.h" 11 | #include "node/detail/node_data.h" 12 | 13 | #include 14 | #include 15 | 16 | namespace YAML { 17 | namespace detail { 18 | template 19 | struct get_idx { 20 | static node* get(const std::vector& /* sequence */, 21 | const Key& /* key */, shared_memory_holder /* pMemory */) { 22 | return nullptr; 23 | } 24 | }; 25 | 26 | template 27 | struct get_idx::value && 29 | !std::is_same::value>::type> { 30 | static node* get(const std::vector& sequence, const Key& key, 31 | shared_memory_holder /* pMemory */) { 32 | return key < sequence.size() ? sequence[key] : nullptr; 33 | } 34 | 35 | static node* get(std::vector& sequence, const Key& key, 36 | shared_memory_holder pMemory) { 37 | if (key > sequence.size() || (key > 0 && !sequence[key - 1]->is_defined())) 38 | return nullptr; 39 | if (key == sequence.size()) 40 | sequence.push_back(&pMemory->create_node()); 41 | return sequence[key]; 42 | } 43 | }; 44 | 45 | template 46 | struct get_idx::value>::type> { 47 | static node* get(const std::vector& sequence, const Key& key, 48 | shared_memory_holder pMemory) { 49 | return key >= 0 ? get_idx::get( 50 | sequence, static_cast(key), pMemory) 51 | : nullptr; 52 | } 53 | static node* get(std::vector& sequence, const Key& key, 54 | shared_memory_holder pMemory) { 55 | return key >= 0 ? get_idx::get( 56 | sequence, static_cast(key), pMemory) 57 | : nullptr; 58 | } 59 | }; 60 | 61 | template 62 | struct remove_idx { 63 | static bool remove(std::vector&, const Key&, std::size_t&) { 64 | return false; 65 | } 66 | }; 67 | 68 | template 69 | struct remove_idx< 70 | Key, typename std::enable_if::value && 71 | !std::is_same::value>::type> { 72 | 73 | static bool remove(std::vector& sequence, const Key& key, 74 | std::size_t& seqSize) { 75 | if (key >= sequence.size()) { 76 | return false; 77 | } else { 78 | sequence.erase(sequence.begin() + key); 79 | if (seqSize > key) { 80 | --seqSize; 81 | } 82 | return true; 83 | } 84 | } 85 | }; 86 | 87 | template 88 | struct remove_idx::value>::type> { 90 | 91 | static bool remove(std::vector& sequence, const Key& key, 92 | std::size_t& seqSize) { 93 | return key >= 0 ? remove_idx::remove( 94 | sequence, static_cast(key), seqSize) 95 | : false; 96 | } 97 | }; 98 | 99 | template 100 | inline bool node::equals(const T& rhs, shared_memory_holder pMemory) { 101 | T lhs; 102 | if (convert::decode(Node(*this, pMemory), lhs)) { 103 | return lhs == rhs; 104 | } 105 | return false; 106 | } 107 | 108 | inline bool node::equals(const char* rhs, shared_memory_holder pMemory) { 109 | std::string lhs; 110 | if (convert::decode(Node(*this, std::move(pMemory)), lhs)) { 111 | return lhs == rhs; 112 | } 113 | return false; 114 | } 115 | 116 | // indexing 117 | template 118 | inline node* node_data::get(const Key& key, 119 | shared_memory_holder pMemory) const { 120 | switch (m_type) { 121 | case NodeType::Map: 122 | break; 123 | case NodeType::Undefined: 124 | case NodeType::Null: 125 | return nullptr; 126 | case NodeType::Sequence: 127 | if (node* pNode = get_idx::get(m_sequence, key, pMemory)) 128 | return pNode; 129 | return nullptr; 130 | case NodeType::Scalar: 131 | throw BadSubscript(m_mark, key); 132 | } 133 | 134 | auto it = std::find_if(m_map.begin(), m_map.end(), [&](const kv_pair m) { 135 | return m.first->equals(key, pMemory); 136 | }); 137 | 138 | return it != m_map.end() ? it->second : nullptr; 139 | } 140 | 141 | template 142 | inline node& node_data::get(const Key& key, shared_memory_holder pMemory) { 143 | switch (m_type) { 144 | case NodeType::Map: 145 | break; 146 | case NodeType::Undefined: 147 | case NodeType::Null: 148 | case NodeType::Sequence: 149 | if (node* pNode = get_idx::get(m_sequence, key, pMemory)) { 150 | m_type = NodeType::Sequence; 151 | return *pNode; 152 | } 153 | 154 | convert_to_map(pMemory); 155 | break; 156 | case NodeType::Scalar: 157 | throw BadSubscript(m_mark, key); 158 | } 159 | 160 | auto it = std::find_if(m_map.begin(), m_map.end(), [&](const kv_pair m) { 161 | return m.first->equals(key, pMemory); 162 | }); 163 | 164 | if (it != m_map.end()) { 165 | return *it->second; 166 | } 167 | 168 | node& k = convert_to_node(key, pMemory); 169 | node& v = pMemory->create_node(); 170 | insert_map_pair(k, v); 171 | return v; 172 | } 173 | 174 | template 175 | inline bool node_data::remove(const Key& key, shared_memory_holder pMemory) { 176 | if (m_type == NodeType::Sequence) { 177 | return remove_idx::remove(m_sequence, key, m_seqSize); 178 | } 179 | 180 | if (m_type == NodeType::Map) { 181 | kv_pairs::iterator it = m_undefinedPairs.begin(); 182 | while (it != m_undefinedPairs.end()) { 183 | kv_pairs::iterator jt = std::next(it); 184 | if (it->first->equals(key, pMemory)) { 185 | m_undefinedPairs.erase(it); 186 | } 187 | it = jt; 188 | } 189 | 190 | auto iter = std::find_if(m_map.begin(), m_map.end(), [&](const kv_pair m) { 191 | return m.first->equals(key, pMemory); 192 | }); 193 | 194 | if (iter != m_map.end()) { 195 | m_map.erase(iter); 196 | return true; 197 | } 198 | } 199 | 200 | return false; 201 | } 202 | 203 | // map 204 | template 205 | inline void node_data::force_insert(const Key& key, const Value& value, 206 | shared_memory_holder pMemory) { 207 | switch (m_type) { 208 | case NodeType::Map: 209 | break; 210 | case NodeType::Undefined: 211 | case NodeType::Null: 212 | case NodeType::Sequence: 213 | convert_to_map(pMemory); 214 | break; 215 | case NodeType::Scalar: 216 | throw BadInsert(); 217 | } 218 | 219 | node& k = convert_to_node(key, pMemory); 220 | node& v = convert_to_node(value, pMemory); 221 | insert_map_pair(k, v); 222 | } 223 | 224 | template 225 | inline node& node_data::convert_to_node(const T& rhs, 226 | shared_memory_holder pMemory) { 227 | Node value = convert::encode(rhs); 228 | value.EnsureNodeExists(); 229 | pMemory->merge(*value.m_pMemory); 230 | return *value.m_pNode; 231 | } 232 | } 233 | } 234 | 235 | #endif // NODE_DETAIL_IMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 236 | --------------------------------------------------------------------------------