suri435
suri435

Reputation: 11

How to get the Sequence name using yaml-cpp

Refering to this question yaml-cpp read sequence in item

If the yaml looks like

sensors:
  - id1:
      hardwareId: 28-000005a32133
      type: 1
  - id2:
      hardwareId: 28-000005a32132
      type: 4

How to get the name of the sequence from the node ? Using the sensors node how can i get the names of id1 and id2 ?

Upvotes: 1

Views: 587

Answers (1)

Jesse Beder
Jesse Beder

Reputation: 34054

Just iterate through the node; you get key/value pairs:

for (const auto& kv : node["sensors"]) {
  kv.first.as<std::string>();  // "id1" or "id2"
}

Upvotes: 2

Related Questions