### YAML Sequence and Mapping Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html A basic example showing a YAML sequence (list) and a mapping (dictionary). ```yaml sequence: - one - two mapping: ? sky : blue sea : green ``` -------------------------------- ### YAML Anchor and Alias Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html A basic example of YAML anchors and aliases to demonstrate data referencing. ```yaml First occurrence: &anchor Value Second occurrence: *anchor ``` -------------------------------- ### YAML List Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Demonstrates a simple YAML list of strings. ```yaml - Mark McGwire - Sammy Sosa - Ken Griffey ``` -------------------------------- ### YAML Set Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Demonstrates a YAML set, which is a sequence of unique keys. ```yaml --- !!set ? Mark McGwire ? Sammy Sosa ? Ken Griffey ``` -------------------------------- ### YAML Anchors and Aliases Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Demonstrates YAML anchors (&) and aliases (*) for reusing data. ```yaml --- hr: - Mark McGwire # Following node labeled SS - &SS Sammy Sosa rbi: - *SS # Subsequent occurrence - Ken Griffey ``` -------------------------------- ### YAML::EmitFromEvents::OnDocumentStart Source: https://codedocs.xyz/jbeder/yaml-cpp/classYAML_1_1EmitFromEvents-members.html Handles the event when a document starts. ```APIDOC ## OnDocumentStart ### Description Handles the event when a document starts. ### Parameters * **mark** (const Mark &) - The location of the document start. ### Method override ``` -------------------------------- ### YAML Anchor and Alias Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Shows how to define an anchor (&) and use an alias (*) to refer to it. ```yaml anchored: !local &anchor value alias: *anchor ``` -------------------------------- ### YAML::EmitFromEvents::OnMapStart Source: https://codedocs.xyz/jbeder/yaml-cpp/classYAML_1_1EmitFromEvents-members.html Handles the event when a map starts. ```APIDOC ## OnMapStart ### Description Handles the event when a map starts. ### Parameters * **mark** (const Mark &) - The location of the map start. * **tag** (const std::string &) - The tag of the map. * **anchor** (anchor_t) - The anchor of the map. * **style** (EmitterStyle::value) - The style of the map. ### Method override ``` -------------------------------- ### OnDocumentStart(const Mark &mark) override Source: https://codedocs.xyz/jbeder/yaml-cpp/classYAML_1_1NodeBuilder-members.html Called when the start of a YAML document is reached. ```APIDOC ## OnDocumentStart(const Mark &mark) override ### Description Called automatically when the start of a YAML document is encountered during parsing. ### Method Override ### Parameters - **mark** (const Mark &) - The mark indicating the start of the document. ``` -------------------------------- ### YAML::EmitFromEvents::OnSequenceStart Source: https://codedocs.xyz/jbeder/yaml-cpp/classYAML_1_1EmitFromEvents-members.html Handles the event when a sequence starts. ```APIDOC ## OnSequenceStart ### Description Handles the event when a sequence starts. ### Parameters * **mark** (const Mark &) - The location of the sequence start. * **tag** (const std::string &) - The tag of the sequence. * **anchor** (anchor_t) - The anchor of the sequence. * **style** (EmitterStyle::value) - The style of the sequence. ### Method override ``` -------------------------------- ### YAML List of Products Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html A YAML list representing purchased products with item names and quantities. ```yaml --- # Products purchased - item : Super Hoop quantity: 1 - item : Basketball quantity: 4 - item : Big Shoes quantity: 1 ``` -------------------------------- ### YAML Tags and Binary Data Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Demonstrates custom tags ('!!str', '!!binary', '!something') and how to represent binary data in YAML. ```yaml --- not-date: !!str 2002-04-28 picture: !!binary | R0lGODlhDAAMAIQAAP//9/X 17unp5WZmZgAAAOfn515eXv Pz7Y6OjuDg4J+fn5OTk6enp 56enmleECcgggoBADs= application specific tag: !something | The semantics of the tag above may be different for different documents. ``` -------------------------------- ### YAML Question-Answer Pairs Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Shows YAML syntax for representing question-answer pairs using '?' and ':' keys. ```yaml ? - Detroit Tigers - Chicago cubs : - 2001-07-23 ? [ New York Yankees, Atlanta Braves ] : [ 2001-07-02, 2001-08-12, 2001-08-14 ] ``` -------------------------------- ### YAML Invoice Example with Anchors Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Illustrates a complex YAML structure for an invoice, including anchors (&) and aliases (*). ```yaml --- ! invoice: 34843 date : 2001-01-23 bill-to: &id001 given : Chris family : Dumars address: lines: | 458 Walkman Dr. Suite #292 city : Royal Oak state : MI postal : 48046 ship-to: *id001 product: - sku : BL394D quantity : 4 description : Basketball price : 450.00 - sku : BL4438H quantity : 1 description : Super Hoop price : 2392.00 tax : 251.42 total: 4443.52 comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338. ``` -------------------------------- ### YAML Comment Only Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html A YAML file containing only comments. ```yaml # Comment only. ``` -------------------------------- ### YAML Map Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Shows a YAML map with key-value pairs representing player statistics. ```yaml hr: 65 # Home runs avg: 0.278 # Batting average rbi: 147 # Runs Batted In ``` -------------------------------- ### YAML Bad Escapes Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Shows examples of invalid escape sequences in YAML strings, which may result in warnings or errors. ```yaml Bad escapes: "\ \xq-" ``` -------------------------------- ### YAML List with Inline Maps Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Shows a YAML list where elements are inline maps. ```yaml - [name , hr, avg ] - [Mark McGwire, 65, 0.278] - [Sammy Sosa , 63, 0.288] ``` -------------------------------- ### YAML Map with Inline Maps Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Demonstrates a YAML map where values are inline maps. ```yaml Mark McGwire: {hr: 65, avg: 0.278} Sammy Sosa: { hr: 63, avg: 0.288 } ``` -------------------------------- ### YAML Multi-Document Log Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Demonstrates a YAML file containing multiple documents, separated by '---', often used for log files. ```yaml --- Time: 2001-11-23 15:01:42 -5 User: ed Warning: This is an error message for the log file --- Time: 2001-11-23 15:02:31 -5 User: ed Warning: A slightly different error message. --- Date: 2001-11-23 15:03:17 -5 User: ed Fatal: Unknown variable "bar" Stack: - file: TopClass.py line: 23 code: | x = MoreObject("345\ ") - file: MoreClass.py line: 58 code: |- foo = bar ``` -------------------------------- ### Define DocStart RegEx Source: https://codedocs.xyz/jbeder/yaml-cpp/exp_8h_source.html Returns a RegEx object that matches the YAML document start indicator '---', followed by optional whitespace or a line break. ```cpp inline const RegEx& DocStart() { static const RegEx e = RegEx("---") + (BlankOrBreak() | RegEx()); return e; } ``` -------------------------------- ### YAML Set Representation Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Explains how sets are represented in YAML using mappings where keys are elements. ```yaml # Sets are represented as a # Mapping where each key is ``` -------------------------------- ### YAML Empty Lines and Comments Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Example of a YAML structure with empty lines and comments. ```yaml # Comment ``` -------------------------------- ### YAML with Multiple Tag Definitions Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Shows how to define a tag alias and then use it for different types, like 'light' in this example. ```yaml %TAG !m! !my- --- # Bulb here !m!light fluorescent ... %TAG !m! !my- --- # Color here !m!light green ``` -------------------------------- ### OnMapStart(const Mark &mark, const std::string &tag, anchor_t anchor, EmitterStyle::value style) override Source: https://codedocs.xyz/jbeder/yaml-cpp/classYAML_1_1NodeBuilder-members.html Called when the start of a YAML map is reached. ```APIDOC ## OnMapStart(const Mark &mark, const std::string &tag, anchor_t anchor, EmitterStyle::value style) override ### Description Called automatically when the start of a map structure in the YAML input is encountered. ### Method Override ### Parameters - **mark** (const Mark &) - The mark indicating the start of the map. - **tag** (const std::string &) - The tag associated with the map. - **anchor** (anchor_t) - The anchor name of the map. - **style** (EmitterStyle::value) - The emission style of the map. ``` -------------------------------- ### YAML List of Maps Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Represents a list where each item is a map with player details. ```yaml - name: Mark McGwire hr: 65 avg: 0.278 - name: Sammy Sosa hr: 63 avg: 0.288 ``` -------------------------------- ### YAML Nested List Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Illustrates a YAML map containing lists of strings. ```yaml american: - Boston Red Sox - Detroit Tigers - New York Yankees national: - New York Mets - Chicago Cubs - Atlanta Braves ``` -------------------------------- ### OnSequenceStart(const Mark &mark, const std::string &tag, anchor_t anchor, EmitterStyle::value style) override Source: https://codedocs.xyz/jbeder/yaml-cpp/classYAML_1_1NodeBuilder-members.html Called when the start of a YAML sequence is reached. ```APIDOC ## OnSequenceStart(const Mark &mark, const std::string &tag, anchor_t anchor, EmitterStyle::value style) override ### Description Called automatically when the start of a sequence structure in the YAML input is encountered. ### Method Override ### Parameters - **mark** (const Mark &) - The mark indicating the start of the sequence. - **tag** (const std::string &) - The tag associated with the sequence. - **anchor** (anchor_t) - The anchor name of the sequence. - **style** (EmitterStyle::value) - The emission style of the sequence. ``` -------------------------------- ### YAML Multi-Document Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Shows two distinct YAML documents, each representing a different event log entry. ```yaml --- time: 20:03:20 player: Sammy Sosa action: strike (miss) ... --- time: 20:03:47 player: Sammy Sosa action: grand slam ... ``` -------------------------------- ### YAML Date and Timestamp Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Illustrates YAML's support for ISO 8601 date and timestamp formats. ```yaml canonical: 2001-12-15T02:59:43.1Z iso8601: 2001-12-14t21:59:43.10-05:00 spaced: 2001-12-14 21:59:43.10 -5 date: 2002-12-14 ``` -------------------------------- ### YAML with Tabs and Block Scalar Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Example demonstrating the use of tabs within quoted strings and block scalars. ```yaml # Tabs and spaces quoted: "Quoted\t" block: | void main() { printf("Hello, world!\n"); } ``` -------------------------------- ### YAML with Mixed Tags and Local Tags Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html A YAML example combining global tags, local tags, and standard types within a list. ```yaml %TAG !e! tag:example.com,2000:app/ --- - !local foo - !!str bar - !e!tag%21 baz ``` -------------------------------- ### YAML Null and Boolean Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Shows the representation of null values and boolean types in YAML. ```yaml null: booleans: [ true, false ] string: '012345' ``` -------------------------------- ### YAML Document Separator Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Illustrates the use of '---' to separate multiple YAML documents within a single stream. ```yaml # Ranking of 1998 home runs --- - Mark McGwire - Sammy Sosa - Ken Griffey # Team ranking --- - Chicago Cubs - St Louis Cardinals ``` -------------------------------- ### YAML Tag Directive Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Example of using a tag directive to define a custom tag prefix. ```yaml %TAG !yaml! tag:yaml.org,2002: --- !yaml!str "foo" ``` -------------------------------- ### YAML Custom Tags and Aliases Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Shows how to use custom tags with anchors and aliases for defining and referencing complex structures like shapes. ```yaml %TAG ! tag:clarkevans.com,2002: --- !shape # Use the ! handle for presenting # tag:clarkevans.com,2002:circle - !circle center: &ORIGIN {x: 73, y: 129} radius: 7 - !line start: *ORIGIN finish: { x: 89, y: 102 } - !label start: *ORIGIN color: 0xFFEEBB text: Pretty vector drawing. ``` -------------------------------- ### YAML Integer Representations Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Illustrates different ways to represent integers in YAML, including canonical, decimal, octal, and hexadecimal. ```yaml canonical: 12345 decimal: +12345 octal: 0o14 hexadecimal: 0xC ``` -------------------------------- ### YAML String Escaping Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Demonstrates various string escaping mechanisms in YAML, including Unicode, control characters, and hex escapes. ```yaml unicode: "Sosa did fine.\☺" control: "\1998\ 1999\ 2000\ " hex esc: "\ \ x is \ \ " single: '"Howdy!" he cried.' quoted: ' # Not a ''comment''.' tie-fighter: '|\\-*-/|' ``` -------------------------------- ### YAML Ordered Map Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Shows an ordered map (omap) in YAML, represented as a sequence of mappings. ```yaml --- !!omap - Mark McGwire: 65 - Sammy Sosa: 63 - Ken Griffey: 58 ``` -------------------------------- ### YAML Floating Point Representations Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Demonstrates various representations for floating-point numbers in YAML, including scientific notation and special values. ```yaml canonical: 1.23015e+3 exponential: 12.3015e+02 fixed: 1230.15 negative infinity: -.inf not a number: .NaN ``` -------------------------------- ### Get Node Type Source: https://codedocs.xyz/jbeder/yaml-cpp/detail_2node_8h_source.html Returns the type of the node. ```cpp NodeType::value type() const { return m_pRef->type(); } ``` -------------------------------- ### YAML Unquoted and Quoted Scalars Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Shows how YAML handles unquoted and quoted scalars that span multiple lines. ```yaml plain: This unquoted scalar spans many lines. quoted: "So does this quoted scalar.\ " ``` -------------------------------- ### Basic YAML String with Tags Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Demonstrates a simple YAML string with a custom tag. Ensure the tag is correctly defined and used. ```yaml %TAG ! !foo %TAG ! !foo bar ``` -------------------------------- ### Get Emitter Style Source: https://codedocs.xyz/jbeder/yaml-cpp/detail_2node_8h_source.html Retrieves the emitter style for the node. ```cpp EmitterStyle::value style() const { return m_pRef->style(); } ``` -------------------------------- ### Get Node Tag Source: https://codedocs.xyz/jbeder/yaml-cpp/detail_2node_8h_source.html Retrieves the tag associated with the node. ```cpp const std::string& tag() const { return m_pRef->tag(); } ``` -------------------------------- ### YAML Handler Test Class Setup Source: https://codedocs.xyz/jbeder/yaml-cpp/handler__test_8h_source.html Sets up a test class for YAML event handlers, including mock handlers and a sequence for strict mock event ordering. This is used for testing parser behavior with event handlers. ```cpp #include "mock_event_handler.h" #include "yaml-cpp/yaml.h" // IWYU pragma: keep #include "gmock/gmock.h" #include "gtest/gtest.h" using ::testing::InSequence; using ::testing::NiceMock; using ::testing::StrictMock; namespace YAML { class HandlerTest : public ::testing::Test { protected: void Parse(const std::string& example) { std::stringstream stream(example); Parser parser(stream); while (parser.HandleNextDocument(handler)) { } } void IgnoreParse(const std::string& example) { std::stringstream stream(example); Parser parser(stream); while (parser.HandleNextDocument(nice_handler)) { } } InSequence sequence; StrictMock handler; NiceMock nice_handler; }; } ``` -------------------------------- ### Get Scalar Value Source: https://codedocs.xyz/jbeder/yaml-cpp/detail_2node_8h_source.html Retrieves the scalar string value of the node. ```cpp const std::string& scalar() const { return m_pRef->scalar(); } ``` -------------------------------- ### Get Node Mark Source: https://codedocs.xyz/jbeder/yaml-cpp/detail_2node_8h_source.html Retrieves the source mark associated with the node. ```cpp const Mark& mark() const { return m_pRef->mark(); } ``` -------------------------------- ### __init__ Source: https://codedocs.xyz/jbeder/yaml-cpp/classcreate-emitter-tests_1_1Writer-members.html Initializes the Writer object. It takes an output stream as an argument. ```APIDOC ## __init__ ### Description Initializes the Writer object. It takes an output stream as an argument. ### Method __init__ ### Parameters #### Path Parameters - **out** (object) - Required - The output stream to write to. ``` -------------------------------- ### YAML Directive Ignored Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Example of a YAML directive ('%FOO') that should be ignored with a warning. ```yaml %FOO bar baz # Should be ignored # with a warning. --- "foo" ``` -------------------------------- ### Get Node Size Source: https://codedocs.xyz/jbeder/yaml-cpp/detail_2node_8h_source.html Returns the number of elements in the node (for sequences and mappings). ```cpp std::size_t size() const { return m_pRef->size(); } ``` -------------------------------- ### Get(anchor_t anchor) const Source: https://codedocs.xyz/jbeder/yaml-cpp/classYAML_1_1AnchorDict-members.html Retrieves a value associated with a given anchor. ```APIDOC ## Get(anchor_t anchor) const ### Description Retrieves a value associated with a given anchor. ### Method Member function ### Endpoint N/A ### Parameters #### Path Parameters - **anchor** (anchor_t) - Description of the anchor parameter. ### Request Example N/A ### Response #### Success Response - Returns the value associated with the anchor. #### Response Example N/A ``` -------------------------------- ### Build yaml-cpp with CMake Source: https://codedocs.xyz/jbeder/yaml-cpp/index.html Navigate to the source directory, create a build folder, and run CMake to configure the build. Specify a generator for your build system and optionally set build options like creating shared libraries. ```bash mkdir build cd build cmake [-G generator] [-DYAML_BUILD_SHARED_LIBS=on|OFF] .. ``` -------------------------------- ### YAML Folded Scalar with Newlines Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Example of a folded scalar ('>') preserving newlines and spaces. ```yaml > foo bar baz ``` -------------------------------- ### Compute floor(log5(2^p)) - log5(3)) Source: https://codedocs.xyz/jbeder/yaml-cpp/dragonbox_8h_source.html Calculates floor(log5(2^p)) - log5(3)) using a template-based implementation. It requires specifying minimum and maximum exponent values and the desired return type. ```cpp template ::default_return_type, class Int> constexpr ReturnType floor_log5_pow2_minus_log5_3(Int e) noexcept { return compute_impl::template compute(e); } ``` -------------------------------- ### Node::Tag Source: https://codedocs.xyz/jbeder/yaml-cpp/impl_8h_source.html Gets the tag of the YAML node. Throws an exception if the node is invalid. ```APIDOC ## Node::Tag ### Description Retrieves the tag associated with this YAML node. If the node is invalid, an `InvalidNode` exception is thrown. ### Method `const std::string& Tag() const` ### Parameters None ### Returns A constant reference to the node's tag string. Returns an empty scalar if the node pointer is null. ### Exceptions - `InvalidNode`: If the node is not valid. ``` -------------------------------- ### Get Source: https://codedocs.xyz/jbeder/yaml-cpp/classYAML_1_1AnchorDict.html Retrieves the value associated with a given anchor_t. This function is const and does not modify the AnchorDict. ```APIDOC ## Get ### Description Retrieves the value associated with a given anchor_t. ### Signature `T Get(anchor_t anchor) const` ### Parameters - **anchor** (`anchor_t`) - The anchor whose associated value is to be retrieved. ### Returns `T` - The value associated with the anchor. ``` -------------------------------- ### __init__ Source: https://codedocs.xyz/jbeder/yaml-cpp/classcreate-emitter-tests_1_1Scope-members.html Initializes a new instance of the Scope class. ```APIDOC ## __init__ ### Description Initializes a new instance of the Scope class. ### Signature `__init__(self, writer, name, indent)` ### Parameters * **writer**: The writer object. * **name**: The name of the scope. * **indent**: The indentation level. ### Defined in create-emitter-tests.Scope ``` -------------------------------- ### YAML Flow Style Sequence and Mapping Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Demonstrates YAML sequences and mappings using the more compact flow style syntax. ```yaml sequence: [ one, two, ] mapping: { sky: blue, sea: green } ``` -------------------------------- ### Emitting a Simple Map Source: https://codedocs.xyz/jbeder/yaml-cpp/md_docs_How-To-Emit-YAML.html Construct a YAML map by using YAML::BeginMap, defining keys with YAML::Key and values with YAML::Value, and finishing with YAML::EndMap. ```cpp YAML::Emitter out; out << YAML::BeginMap; out << YAML::Key << "name"; out << YAML::Value << "Ryan Braun"; out << YAML::Key << "position"; out << YAML::Value << "LF"; out << YAML::EndMap; ``` -------------------------------- ### get Source: https://codedocs.xyz/jbeder/yaml-cpp/structYAML_1_1detail_1_1get__idx-members.html Retrieves an element from a vector of nodes based on a key. This is a static inline member function. ```APIDOC ## get ### Description Retrieves an element from a vector of nodes based on a key. ### Method static inline ### Signature get(const std::vector< node *> & nodes, const Key & key, shared_memory_holder memory_holder) ### Parameters * **nodes** (const std::vector< node *> &) - The vector of node pointers to search within. * **key** (const Key &) - The key to search for. * **memory_holder** (shared_memory_holder) - A holder for shared memory. ### Defined In YAML::detail::get_idx< Key, Enable > ``` -------------------------------- ### Node Reference Indexing Operations Source: https://codedocs.xyz/jbeder/yaml-cpp/node__ref_8h_source.html Provides methods for getting and removing elements by key or index. ```APIDOC ## Indexing Operations ### `get()` (const, Key-based) Retrieves a pointer to a node by key (e.g., map key or sequence index). - **Template Parameters**: - `Key` - The type of the key. - **Parameters**: - `key` (const `Key&`) - The key to look up. - `pMemory` (`shared_memory_holder`) - The memory holder. - **Returns**: `node*` - A pointer to the node if found, otherwise `nullptr`. ```cpp template node* get(const Key& key, shared_memory_holder pMemory) const; ``` ### `get()` (Key-based) Retrieves a reference to a node by key (e.g., map key or sequence index). - **Template Parameters**: - `Key` - The type of the key. - **Parameters**: - `key` (const `Key&`) - The key to look up. - `pMemory` (`shared_memory_holder`) - The memory holder. - **Returns**: `node&` - A reference to the node. ```cpp template node& get(const Key& key, shared_memory_holder pMemory); ``` ### `remove()` (Key-based) Removes a node by key (e.g., map key or sequence index). - **Template Parameters**: - `Key` - The type of the key. - **Parameters**: - `key` (const `Key&`) - The key of the node to remove. - `pMemory` (`shared_memory_holder`) - The memory holder. - **Returns**: `bool` - `true` if the node was removed, `false` otherwise. ```cpp template bool remove(const Key& key, shared_memory_holder pMemory); ``` ### `get()` (const, node-based) Retrieves a pointer to a node by a `node` reference. - **Parameters**: - `key` (`node&`) - The node reference to look up. - `pMemory` (`shared_memory_holder`) - The memory holder. - **Returns**: `node*` - A pointer to the node if found, otherwise `nullptr`. ```cpp node* get(node& key, shared_memory_holder pMemory) const; ``` ### `get()` (node-based) Retrieves a reference to a node by a `node` reference. - **Parameters**: - `key` (`node&`) - The node reference to look up. - `pMemory` (`shared_memory_holder`) - The memory holder. - **Returns**: `node&` - A reference to the node. ```cpp node& get(node& key, shared_memory_holder pMemory); ``` ### `remove()` (node-based) Removes a node by a `node` reference. - **Parameters**: - `key` (`node&`) - The node reference to remove. - `pMemory` (`shared_memory_holder`) - The memory holder. - **Returns**: `bool` - `true` if the node was removed, `false` otherwise. ```cpp bool remove(node& key, shared_memory_holder pMemory); ``` ``` -------------------------------- ### YAML with Custom Tag and Local Tag Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Demonstrates YAML with a custom global tag and a local tag within a list. ```yaml %TAG !e! tag:example,2000:app/ --- - !e! foo ``` ```yaml %TAG !e! tag:example,2000:app/ --- - !h!bar baz ``` -------------------------------- ### Get Node Iterator End Source: https://codedocs.xyz/jbeder/yaml-cpp/detail_2node_8h_source.html Returns a non-const iterator to the end of the node's elements. ```cpp node_iterator end() { return m_pRef->end(); } ``` -------------------------------- ### Get Node Iterator Begin Source: https://codedocs.xyz/jbeder/yaml-cpp/detail_2node_8h_source.html Returns a non-const iterator to the beginning of the node's elements. ```cpp node_iterator begin() { return m_pRef->begin(); } ``` -------------------------------- ### Emitting a Simple Sequence Source: https://codedocs.xyz/jbeder/yaml-cpp/md_docs_How-To-Emit-YAML.html Construct a YAML sequence by using YAML::BeginSeq, adding elements, and finishing with YAML::EndSeq. ```cpp YAML::Emitter out; out << YAML::BeginSeq; out << "eggs"; out << "bread"; out << "milk"; out << YAML::EndSeq; ``` -------------------------------- ### Get Node Reference Source: https://codedocs.xyz/jbeder/yaml-cpp/detail_2node_8h_source.html Returns a raw pointer to the node's internal reference object. ```cpp const node_ref* ref() const { return m_pRef.get(); } ``` -------------------------------- ### YAML List with Aliased Tag Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Example of a YAML list where elements are tagged using an aliased tag. ```yaml %TAG !e! tag:example.com,2000:app/ --- - !e!foo "bar" ``` -------------------------------- ### GraphBuilderAdapter::OnDocumentStart Source: https://codedocs.xyz/jbeder/yaml-cpp/graphbuilderadapter_8h_source.html Called when a new YAML document begins parsing. ```APIDOC ## OnDocumentStart(const Mark& mark) ### Description This virtual method is called by the event handler system when the parser begins processing a new YAML document. It receives the starting mark of the document. ### Method virtual void OnDocumentStart(const Mark& mark) ### Parameters - **mark** (const Mark&) - The starting position of the document in the input stream. ``` -------------------------------- ### YAML Explicit and Implicit Mappings Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Illustrates YAML mappings with both explicit keys ('?') and implicit keys. ```yaml { ? explicit: entry, implicit: entry, ? } ``` -------------------------------- ### YAML::Setting< T >::Setting (constructor) Source: https://codedocs.xyz/jbeder/yaml-cpp/classYAML_1_1Setting-members.html Constructs a default YAML::Setting object. ```APIDOC ## Setting (constructor) ### Description Constructs a default YAML::Setting object. ### Method inline ### Parameters None ### Returns A new YAML::Setting object. ``` -------------------------------- ### Make Policy Pair List Implementation Source: https://codedocs.xyz/jbeder/yaml-cpp/dragonbox_8h_source.html An implementation detail for constructing a list of found policy pairs by iterating through detector-default pairs. ```cpp template struct found_policy_pair_list { static constexpr bool repeated = repeated_; }; template struct make_policy_pair_list_impl; template struct make_policy_pair_list_impl, found_policy_pair_list, Policies...> { using type = found_policy_pair_list; }; template struct make_policy_pair_list_impl< detector_default_pair_list, found_policy_pair_list, Policies...> { using new_found_policy_pair = typename FirstDetectorDefaultPair::template get_found_policy_pair; using type = typename make_policy_pair_list_impl< detector_default_pair_list, found_policy_pair_list<(repeated || new_found_policy_pair::found_info == policy_found_info::repeated), new_found_policy_pair, FoundPolicyPairs...>, Policies...>::type; }; ``` -------------------------------- ### Node::Style Source: https://codedocs.xyz/jbeder/yaml-cpp/impl_8h_source.html Gets the emitter style of the YAML node. Returns `EmitterStyle::Default` if the node is null. ```APIDOC ## Node::Style ### Description Retrieves the emitter style of the YAML node. If the node is invalid, an `InvalidNode` exception is thrown. If the internal node pointer is null, it defaults to `EmitterStyle::Default`. ### Method `EmitterStyle::value Style() const` ### Parameters None ### Returns The `EmitterStyle::value` of the node. ### Exceptions - `InvalidNode`: If the node is not valid. ``` -------------------------------- ### YAML::Setting< T >::Setting (constructor with value) Source: https://codedocs.xyz/jbeder/yaml-cpp/classYAML_1_1Setting-members.html Constructs a YAML::Setting object with an initial value. ```APIDOC ## Setting (constructor with value) ### Description Constructs a YAML::Setting object with an initial value. ### Method inline ### Parameters - **value** (const T &): The initial value to set for the setting. ### Returns A new YAML::Setting object with the specified initial value. ``` -------------------------------- ### YAML Indentation and Comments Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Demonstrates how leading spaces in comments and flow style are handled, and how indentation affects block scalars. ```yaml # Leading comment line spaces are # neither content nor indentation. Not indented: By one space: | By four spaces Flow style: [ # Leading spaces By two, # in flow style Also by two, # are neither Still by two # content nor ] # indentation. ``` -------------------------------- ### Node Reference Size and Iterators Source: https://codedocs.xyz/jbeder/yaml-cpp/node__ref_8h_source.html Provides methods to get the size of the node and iterators for traversing its elements. ```APIDOC ## Size and Iterators ### `size()` Returns the number of elements in the node. - **Returns**: `std::size_t` - The number of elements. ```cpp std::size_t size() const; ``` ### `begin()` (const) Returns a const iterator to the beginning of the node's elements. - **Returns**: `const_node_iterator` - An iterator to the beginning. ```cpp const_node_iterator begin() const; ``` ### `begin()` Returns an iterator to the beginning of the node's elements. - **Returns**: `node_iterator` - An iterator to the beginning. ```cpp node_iterator begin(); ``` ### `end()` (const) Returns a const iterator to the end of the node's elements. - **Returns**: `const_node_iterator` - An iterator to the end. ```cpp const_node_iterator end() const; ``` ### `end()` Returns an iterator to the end of the node's elements. - **Returns**: `node_iterator` - An iterator to the end. ```cpp node_iterator end(); ``` ``` -------------------------------- ### YAML with Anchors and Aliases Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Demonstrates the use of anchors and aliases in YAML for data reuse. Anchors define a reference point, and aliases reuse that data. ```yaml !!str &a1 "foo": !!str bar &a2 baz : *a1 ``` -------------------------------- ### Get Constant Node Iterator End Source: https://codedocs.xyz/jbeder/yaml-cpp/detail_2node_8h_source.html Returns a const iterator to the end of the node's elements. ```cpp const_node_iterator end() const { return static_cast(*m_pRef).end(); } ``` -------------------------------- ### Basic Type Conversions with yaml-cpp Source: https://codedocs.xyz/jbeder/yaml-cpp/md_docs_Tutorial.html Shows how to convert between YAML nodes and C++ native types like double, and how to assign native types to YAML nodes. Also demonstrates conversion from a YAML sequence to a std::vector. ```cpp YAML::Node node = YAML::Load("{pi: 3.14159, [0, 1]: integers}"); // this needs the conversion from Node to double double pi = node["pi"].as(); // this needs the conversion from double to Node node["e"] = 2.71828; // this needs the conversion from Node to std::vector (*not* the other way around!) std::vector v; v.push_back(0); v.push_back(1); std::string str = node[v].as(); ``` -------------------------------- ### Get Constant Node Iterator Begin Source: https://codedocs.xyz/jbeder/yaml-cpp/detail_2node_8h_source.html Returns a const iterator to the beginning of the node's elements. ```cpp const_node_iterator begin() const { return static_cast(*m_pRef).begin(); } ``` -------------------------------- ### YAML Complex Key and Value Structure Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Example of a YAML structure with a complex key (mapping) and nested values. ```yaml ? a : - b - - c - d ``` -------------------------------- ### StartedDoc Source: https://codedocs.xyz/jbeder/yaml-cpp/classYAML_1_1EmitterState-members.html Marks the beginning of a YAML document. ```APIDOC ## StartedDoc ### Description Marks the beginning of a YAML document. ### Method void StartedDoc() ### Parameters None. ``` -------------------------------- ### restore() Source: https://codedocs.xyz/jbeder/yaml-cpp/classYAML_1_1SettingChanges-members.html Restores the settings to a previous state. This method is marked as noexcept. ```APIDOC ## restore() ### Description Restores settings. ### Method inline ### Throws YAML_CPP_NOEXCEPT ``` -------------------------------- ### __enter__ Source: https://codedocs.xyz/jbeder/yaml-cpp/classcreate-emitter-tests_1_1Scope-members.html Enters a runtime context related to this object. Used for context management. ```APIDOC ## __enter__ ### Description Enters a runtime context related to this object. Used for context management. ### Signature `__enter__(self)` ### Defined in create-emitter-tests.Scope ``` -------------------------------- ### Constructors Source: https://codedocs.xyz/jbeder/yaml-cpp/classYAML_1_1Binary-members.html Constructors for the YAML::Binary class. ```APIDOC ## Binary(const unsigned char *data_, std::size_t size_) ### Description Constructs a Binary object with the given data and size. ### Method Constructor ### Parameters - **data_** (const unsigned char *) - Pointer to the data. - **size_** (std::size_t) - The size of the data. ``` ```APIDOC ## Binary() ### Description Default constructor for YAML::Binary. ### Method Constructor ``` ```APIDOC ## Binary(const Binary &)=default ### Description Copy constructor for YAML::Binary. ### Method Constructor ``` ```APIDOC ## Binary(Binary &&)=default ### Description Move constructor for YAML::Binary. ### Method Constructor ``` -------------------------------- ### Load and Parse YAML Configuration Source: https://codedocs.xyz/jbeder/yaml-cpp/md_docs_Tutorial.html Load a YAML configuration file and access its properties. Use this for reading settings from a file. ```cpp YAML::Node config = YAML::LoadFile("config.yaml"); if (config["lastLogin"]) { std::cout << "Last logged in: " << config["lastLogin"].as() << "\n"; } const std::string username = config["username"].as(); const std::string password = config["password"].as(); login(username, password); config["lastLogin"] = getCurrentDateTime(); std::ofstream fout("config.yaml"); fout << config; ``` -------------------------------- ### Generate Cache and Power-of-5 Tables (Pre-C++17) Source: https://codedocs.xyz/jbeder/yaml-cpp/dragonbox_8h_source.html Generates `cache` and `pow5_table` using helper functions and `std::index_sequence` for compatibility with pre-C++17 standards. Requires `detail::make_index_sequence`. ```cpp template static constexpr cache_holder_t make_cache(detail::index_sequence) { return {cache_holder::cache[indices * compression_ratio]...}; } static constexpr cache_holder_t cache JKJ_STATIC_DATA_SECTION = make_cache(detail::make_index_sequence{}); template static constexpr pow5_holder_t make_pow5_table(detail::index_sequence) { return {detail::compute_power(detail::stdr::uint_least64_t(5))...}; } static constexpr pow5_holder_t pow5_table JKJ_STATIC_DATA_SECTION = make_pow5_table(detail::make_index_sequence{}); ``` -------------------------------- ### YAML Single Quoted String Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Example of a YAML string enclosed in single quotes, demonstrating how to include double quotes within it. ```yaml 'here''s to "quotes"' ``` -------------------------------- ### Pre-C++17 Static Power-of-5 Table Initialization Source: https://codedocs.xyz/jbeder/yaml-cpp/dragonbox_8h_source.html Initializes the power-of-5 table using a helper function and index sequences for pre-C++17 compatibility. This approach uses template metaprogramming to generate the table at compile time. ```cpp template static constexpr pow5_holder_t make_pow5_table(detail::index_sequence) { return {detail::compute_power(detail::stdr::uint_least16_t(5))...}; } static constexpr pow5_holder_t pow5_table JKJ_STATIC_DATA_SECTION = make_pow5_table(detail::make_index_sequence{}); ``` -------------------------------- ### KeyNotFound Constructor Source: https://codedocs.xyz/jbeder/yaml-cpp/classYAML_1_1KeyNotFound.html Constructs a KeyNotFound exception with the given mark and key. ```APIDOC ## KeyNotFound Constructor ### Description Constructs a `KeyNotFound` exception with the given mark and key. ### Signature ```cpp template KeyNotFound(const Mark &mark_, const T &key_) ``` ### Parameters * **mark_** (const Mark &) - The mark associated with the error. * **key_** (const T &) - The key that was not found. ``` -------------------------------- ### Static Member Functions for Binary Exponent and Significand Source: https://codedocs.xyz/jbeder/yaml-cpp/structYAML_1_1jkj_1_1dragonbox_1_1float__bits.html Static methods for calculating binary exponent and significand. ```APIDOC ## Static Member Functions for Binary Exponent and Significand ### Description Static utility functions to compute binary exponent and significand values. ### Methods * **binary_exponent** * Calculates the binary exponent for a given set of exponent bits. * `static constexpr exponent_int binary_exponent(exponent_int exponent_bits) noexcept;` * **binary_significand** * Constructs a binary significand from significand and exponent bits. * `static constexpr carrier_uint binary_significand(carrier_uint significand_bits, exponent_int exponent_bits) noexcept;` ``` -------------------------------- ### YAML Folded Block Scalar Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Shows a folded block scalar ('>') that folds newlines into spaces, useful for long paragraphs. ```yaml --- # Folded block scalar --- > Mark McGwire's year was crippled by a knee injury. ``` -------------------------------- ### YAML::Setting< T >::get Source: https://codedocs.xyz/jbeder/yaml-cpp/classYAML_1_1Setting-members.html Retrieves the value of the setting. ```APIDOC ## get ### Description Retrieves the value of the setting. ### Method const ### Parameters None ### Returns - T: The current value of the setting. ``` -------------------------------- ### YAML Folded Block Scalar with Newlines Example Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Illustrates a folded block scalar ('>') preserving explicit newlines within the folded text. ```yaml > Sammy Sosa completed another fine season with great stats. 63 Home Runs 0.288 Batting Average What a year! ``` -------------------------------- ### Get Node by Key (Non-Const) Source: https://codedocs.xyz/jbeder/yaml-cpp/detail_2node_8h_source.html Retrieves a reference to a node within the current node using a key. The retrieved node is added as a dependency. ```cpp template node& get(const Key& key, shared_memory_holder pMemory) { node& value = m_pRef->get(key, pMemory); value.add_dependency(*this); return value; } ``` -------------------------------- ### Define DocIndicator RegEx Source: https://codedocs.xyz/jbeder/yaml-cpp/exp_8h_source.html Returns a RegEx object that matches either the document start indicator ('---') or the document end indicator ('...'). ```cpp inline const RegEx& DocIndicator() { static const RegEx e = DocStart() | DocEnd(); return e; } ``` -------------------------------- ### Emitter Constructors and Assignment Source: https://codedocs.xyz/jbeder/yaml-cpp/classYAML_1_1Emitter.html Details on how to construct an Emitter object and information about deleted copy constructor and assignment operator. ```APIDOC ## Emitter Constructors and Assignment ### Description Constructs an Emitter object associated with an output stream. Copy construction and assignment are deleted. ### Methods - **Emitter(std::ostream &stream)**: Constructor that takes an output stream. - **Emitter(const Emitter &) = delete**: Deleted copy constructor. - **Emitter &operator=(const Emitter &) = delete**: Deleted assignment operator. ``` -------------------------------- ### YAML with Explicit String and Anchors Source: https://codedocs.xyz/jbeder/yaml-cpp/specexamples_8h_source.html Demonstrates YAML with explicit string types, anchors, aliases, and a standalone explicit string tag. ```yaml - !!str "a" - 'b' - &anchor "c" - *anchor - !!str ```