I am trying to write the following information:
hints:
SoftwareRequirement:
packages:
ApplicationName:
version: [ 1.7.3.nonRelease ]
I am using the following section of code:
std::string m_exeName = # I get this from my CMakeLists file
std::string versionID = # I get this from my CMakeLists file
YAML::Node hints = config["hints"];
config["hints"]["SoftwareRequirement"]["packages"][m_exeName]["version"] = "[ " + versionID + " ]";
And it gets me the following:
hints:
SoftwareRequirement:
packages:
ApplicationName:
version: "[ 1.7.3.nonRelease ]"
Is there any way to get the quotes inside the square bracket or remove them entirely? This is to be in line with the Common Workflow Language (CWL) standard.
Possibly related to this question.
EDIT (added results from answer):
Went with this:
config["hints"]["SoftwareRequirement"]["packages"][m_exeName]["version"][0] = versionID
Result:
hints:
SoftwareRequirement:
packages:
ApplicationName:
version:
- 1.7.3.nonRelease
With is a valid CWL.
[]
are YAML syntax for a sequence; so if you're trying to write
[ 1.7.3.nonRelease ]
then you're trying to write a sequence with a single element 1.7.3.nonRelease
. When you tell yaml-cpp to write the string [ 1.7.3.nonRelease ]
, it notices that if it just pasted the text directly, it would be interpreted as a list, so it quotes the string to prevent that.
If you really want to write a list with one element, then make it so:
config["hints"]["SoftwareRequirement"]["packages"][m_exeName]["version"][0] = versionID;