Review: Misc Yaml Updates


Jeremy Selan <jeremy...@...>
 

A bunch of changes related to yaml serialization:

* ColorSpace transform a base Transform, instead of GroupTransform.
* GroupTransform Yaml serialization supports nesting
* Direction is now serialized for all yaml elements
* Roles survive a yaml round trip
* Most transforms serialize in Flow form for better readability

Commits: js/master

5f53929774b53ebe6dd9f626e320f70a19251592
a417123d6ec39a5df8add746c3047685be7b8553
dc66f63326b7766c70d8bafd392c826a3a8b37d3
8ec63860a00ebf6301d249270ff43f7dadf8f568
a788950e36d107ec07adb1e2daaf8b399fe90936

I am not totally happy with the look of the Yaml output. Ideally, I'd
like to add blank lines after each colorspace definition (this is
valid yaml), but havent been able to figure out how do to so with
yaml-cpp.

http://stackoverflow.com/questions/3982901/how-to-emit-a-blank-line-using-yaml-cpp

-- Jeremy


Malcolm Humphreys <malcolmh...@...>
 

This looks all pretty good to me

A bunch of changes related to yaml serialization:

* ColorSpace transform a base Transform, instead of GroupTransform.
* GroupTransform Yaml serialization supports nesting
* Direction is now serialized for all yaml elements
- Can we call AddBaseTransformPropertiesToYAMLMap = EmitBaseTransformKeyValues
- Can we call ReadBaseTransformPropertiesFromYAMLMap = ReadBaseTransformKeyValues, and can the argument order be swaped to match the other >> operators ie. (TransformRcPtr & t, const YAML::Node & node) -> (const YAML::Node & node, TransformRcPtr &)

* Roles survive a yaml round trip
+1 I like this being a map, I'm not sure if order is important.

* Most transforms serialize in Flow form for better readability

Commits: js/master

5f53929774b53ebe6dd9f626e320f70a19251592
a417123d6ec39a5df8add746c3047685be7b8553
dc66f63326b7766c70d8bafd392c826a3a8b37d3
8ec63860a00ebf6301d249270ff43f7dadf8f568
a788950e36d107ec07adb1e2daaf8b399fe90936

I am not totally happy with the look of the Yaml output. Ideally, I'd
like to add blank lines after each colorspace definition (this is
valid yaml), but havent been able to figure out how do to so with
yaml-cpp.
Yeah most of our yamls are hand written with big breaks between sections, so this hasn't really been an issue.

One possible way would be using YAML::Comment with some new line chars, but it would be much nicer to have something like out << YAML::NewLines(3) that you could use.

void MultiLineComment(YAML::Emitter& out, std::string& desiredOutput)
{
out << YAML::BeginSeq;
out << "item 1" << YAML::Comment("really really long\ncomment that couldn't possibly\nfit on one line");
out << "item 2";
out << YAML::EndSeq;
desiredOutput = "---\n- item 1 # really really long\n # comment that couldn't possibly\n # fit on one line\n- item 2";
}

.malcolm


Malcolm Humphreys <malcolmh...@...>
 

Looking at this quickly it would be a pretty small patch to add out << YAML::NewLines(3);

Something along the lines of:

--emittermanip.h--
struct _NewLines {
_NewLines(int value_): value(value_) {}
int value;
};

inline _NewLines NewLines(int value) {
return _NewLines(value);
}
--emittermanip.h--

-- emitter.h --
...
Emitter& Write(const _NewLines& lines);
...
inline Emitter& operator << (Emitter& emitter, const _NewLines& v) { return emitter.Write(v); }
...
-- emitter.h --

-- emmiter.cpp --
Emitter& Emitter::Write(const _NewLines& lines)
{
if(!good())
return *this;
for(unsigned int i=0; i< lines.value; ++i)
m_stream << "\n";
return *this;
}
-- emmiter.cpp --

.malcolm

On 21/10/2010, at 11:24 AM, Malcolm Humphreys wrote:

This looks all pretty good to me

A bunch of changes related to yaml serialization:

* ColorSpace transform a base Transform, instead of GroupTransform.
* GroupTransform Yaml serialization supports nesting
* Direction is now serialized for all yaml elements
- Can we call AddBaseTransformPropertiesToYAMLMap = EmitBaseTransformKeyValues
- Can we call ReadBaseTransformPropertiesFromYAMLMap = ReadBaseTransformKeyValues, and can the argument order be swaped to match the other >> operators ie. (TransformRcPtr & t, const YAML::Node & node) -> (const YAML::Node & node, TransformRcPtr &)

* Roles survive a yaml round trip
+1 I like this being a map, I'm not sure if order is important.

* Most transforms serialize in Flow form for better readability

Commits: js/master

5f53929774b53ebe6dd9f626e320f70a19251592
a417123d6ec39a5df8add746c3047685be7b8553
dc66f63326b7766c70d8bafd392c826a3a8b37d3
8ec63860a00ebf6301d249270ff43f7dadf8f568
a788950e36d107ec07adb1e2daaf8b399fe90936

I am not totally happy with the look of the Yaml output. Ideally, I'd
like to add blank lines after each colorspace definition (this is
valid yaml), but havent been able to figure out how do to so with
yaml-cpp.
Yeah most of our yamls are hand written with big breaks between sections, so this hasn't really been an issue.

One possible way would be using YAML::Comment with some new line chars, but it would be much nicer to have something like out << YAML::NewLines(3) that you could use.

void MultiLineComment(YAML::Emitter& out, std::string& desiredOutput)
{
out << YAML::BeginSeq;
out << "item 1" << YAML::Comment("really really long\ncomment that couldn't possibly\nfit on one line");
out << "item 2";
out << YAML::EndSeq;
desiredOutput = "---\n- item 1 # really really long\n # comment that couldn't possibly\n # fit on one line\n- item 2";
}

.malcolm


Jeremy Selan <jeremy...@...>
 

- Can we call AddBaseTransformPropertiesToYAMLMap = EmitBaseTransformKeyValues
- Can we call ReadBaseTransformPropertiesFromYAMLMap = ReadBaseTransformKeyValues, and can the argument order be swaped to match the other >> operators ie. (TransformRcPtr & t, const YAML::Node & node) -> (const YAML::Node & node, TransformRcPtr &)
Done.
-- jeremy