YAML CPP: Reorder function definitions
@@ -251,12 +251,8 @@ void addEmptyArrayElements (YAML::Node & sequence, unsigned long long const numb
* @param keyIterator This iterator specifies the current part of the key name this function adds to `data`.
* @param key This parameter specifies the key that should be added to `data`.
*/
-void addKeyArray (YAML::Node & data, NameIterator & keyIterator, Key & key)
+void addKeyNoArray (YAML::Node & data, NameIterator & keyIterator, Key & key)
{
- auto const isArrayAndIndex = isArrayIndex (keyIterator);
- auto const isArrayElement = isArrayAndIndex.first;
- auto const arrayIndex = isArrayAndIndex.second;
-
if (data.IsScalar ()) data = YAML::Node (YAML::NodeType::Undefined);
#ifdef HAVE_LOGGER
@@ -272,33 +268,16 @@ void addKeyArray (YAML::Node & data, NameIterator & keyIterator, Key & key)
return;
}
if (keyIterator == --key.end ())
- {
- if (isArrayElement)
- {
- addEmptyArrayElements (data, arrayIndex - data.size ());
- data.push_back (createLeafNode (key));
- }
- else
{
data[*keyIterator] = createLeafNode (key);
- }
-
return;
}
YAML::Node node;
- if (isArrayElement)
- {
- node = (data[arrayIndex] && !data[arrayIndex].IsScalar ()) ? data[arrayIndex] : YAML::Node ();
- data[arrayIndex] = node;
- }
- else
- {
node = (data[*keyIterator] && !data[*keyIterator].IsScalar ()) ? data[*keyIterator] : YAML::Node ();
data[*keyIterator] = node;
- }
- addKeyArray (node, ++keyIterator, key);
+ addKeyNoArray (node, ++keyIterator, key);
}
/**
@@ -308,8 +287,12 @@ void addKeyArray (YAML::Node & data, NameIterator & keyIterator, Key & key)
* @param keyIterator This iterator specifies the current part of the key name this function adds to `data`.
* @param key This parameter specifies the key that should be added to `data`.
*/
-void addKeyNoArray (YAML::Node & data, NameIterator & keyIterator, Key & key)
+void addKeyArray (YAML::Node & data, NameIterator & keyIterator, Key & key)
{
+ auto const isArrayAndIndex = isArrayIndex (keyIterator);
+ auto const isArrayElement = isArrayAndIndex.first;
+ auto const arrayIndex = isArrayAndIndex.second;
+
if (data.IsScalar ()) data = YAML::Node (YAML::NodeType::Undefined);
#ifdef HAVE_LOGGER
@@ -325,16 +308,33 @@ void addKeyNoArray (YAML::Node & data, NameIterator & keyIterator, Key & key)
return;
}
if (keyIterator == --key.end ())
+ {
+ if (isArrayElement)
+ {
+ addEmptyArrayElements (data, arrayIndex - data.size ());
+ data.push_back (createLeafNode (key));
+ }
+ else
{
data[*keyIterator] = createLeafNode (key);
+ }
+
return;
}
YAML::Node node;
+ if (isArrayElement)
+ {
+ node = (data[arrayIndex] && !data[arrayIndex].IsScalar ()) ? data[arrayIndex] : YAML::Node ();
+ data[arrayIndex] = node;
+ }
+ else
+ {
node = (data[*keyIterator] && !data[*keyIterator].IsScalar ()) ? data[*keyIterator] : YAML::Node ();
data[*keyIterator] = node;
- addKeyNoArray (node, ++keyIterator, key);
+ }
+ addKeyArray (node, ++keyIterator, key);
}
/**
