From ebdfeb034968becd694adb90d9e99c69c86981db Mon Sep 17 00:00:00 2001 From: Jesse Beder Date: Tue, 15 Mar 2011 05:49:56 +0000 Subject: [PATCH] Removed comparison/implicit conversion operators for Node, and renamed Node::Read() to Node::to() --- include/yaml-cpp/node.h | 23 +- include/yaml-cpp/nodeimpl.h | 44 +-- test/parsertests.cpp | 25 +- test/spectests.cpp | 598 ++++++++++++++++++------------------ 4 files changed, 312 insertions(+), 378 deletions(-) diff --git a/include/yaml-cpp/node.h b/include/yaml-cpp/node.h index c0fa379..17ef8e0 100644 --- a/include/yaml-cpp/node.h +++ b/include/yaml-cpp/node.h @@ -62,10 +62,7 @@ namespace YAML bool Read(T& value) const; template - const T Read() const; - - template - operator T() const; + const T to() const; template friend void operator >> (const Node& node, T& value); @@ -127,24 +124,6 @@ namespace YAML node_seq m_seqData; node_map m_mapData; }; - - // comparisons with auto-conversion - template - bool operator == (const T& value, const Node& node); - - template - bool operator == (const Node& node, const T& value); - - template - bool operator != (const T& value, const Node& node); - - template - bool operator != (const Node& node, const T& value); - - bool operator == (const char *value, const Node& node); - bool operator == (const Node& node, const char *value); - bool operator != (const char *value, const Node& node); - bool operator != (const Node& node, const char *value); } #include "yaml-cpp/nodeimpl.h" diff --git a/include/yaml-cpp/nodeimpl.h b/include/yaml-cpp/nodeimpl.h index 21dc276..d26968a 100644 --- a/include/yaml-cpp/nodeimpl.h +++ b/include/yaml-cpp/nodeimpl.h @@ -13,16 +13,11 @@ namespace YAML { // implementation of templated things template - inline const T Node::Read() const { + inline const T Node::to() const { T value; *this >> value; return value; } - - template - Node::operator T() const { - return Read(); - } template inline void operator >> (const Node& node, T& value) { @@ -77,43 +72,6 @@ namespace YAML inline const Node& Node::operator [] (const char *key) const { return GetValue(std::string(key)); } - - template - inline bool operator == (const T& value, const Node& node) { - return value == node.operator T(); - } - - template - inline bool operator == (const Node& node, const T& value) { - return value == node.operator T(); - } - - template - inline bool operator != (const T& value, const Node& node) { - return value != node.operator T(); - } - - template - inline bool operator != (const Node& node, const T& value) { - return value != node.operator T(); - } - - inline bool operator == (const char *value, const Node& node) { - return std::string(value) == node; - } - - inline bool operator == (const Node& node, const char *value) { - return std::string(value) == node; - } - - inline bool operator != (const char *value, const Node& node) { - return std::string(value) != node; - } - - inline bool operator != (const Node& node, const char *value) { - return std::string(value) != node; - } - } #endif // NODEIMPL_H_62B23520_7C8E_11DE_8A39_0800200C9A66 diff --git a/test/parsertests.cpp b/test/parsertests.cpp index 74e0801..7b4174e 100644 --- a/test/parsertests.cpp +++ b/test/parsertests.cpp @@ -132,14 +132,11 @@ namespace Test parser.GetNextDocument(doc); std::string output; - doc[0] >> output; - if(output != "eggs") + if(doc[0].to() != "eggs") return false; - doc[1] >> output; - if(output != "bread") + if(doc[1].to() != "bread") return false; - doc[2] >> output; - if(output != "milk") + if(doc[2].to() != "milk") return false; return true; @@ -626,7 +623,7 @@ namespace Test return false; if(!IsNull(doc["key"])) return false; - if(doc["just a key"] != "value") + if(doc["just a key"].to() != "value") return false; return true; @@ -647,13 +644,13 @@ namespace Test parser.GetNextDocument(doc); if(doc.size() != 4) return false; - if(doc[0] != 15) + if(doc[0].to() != 15) return false; - if(doc[1] != 0x10) + if(doc[1].to() != 0x10) return false; - if(doc[2] != 030) + if(doc[2].to() != 030) return false; - if(doc[3] != 0xffffffff) + if(doc[3].to() != 0xffffffff) return false; return true; } @@ -698,11 +695,11 @@ namespace Test YAML::Node doc; parser.GetNextDocument(doc); - if(doc["a"] != 4) + if(doc["a"].to() != 4) return false; - if(doc["b"] != 2) + if(doc["b"].to() != 2) return false; - if(doc["c"] != 3) + if(doc["c"].to() != 3) return false; return true; } diff --git a/test/spectests.cpp b/test/spectests.cpp index 7ee7d11..f3f05bc 100644 --- a/test/spectests.cpp +++ b/test/spectests.cpp @@ -56,9 +56,9 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); - YAML_ASSERT(doc[0] == "Mark McGwire"); - YAML_ASSERT(doc[1] == "Sammy Sosa"); - YAML_ASSERT(doc[2] == "Ken Griffey"); + YAML_ASSERT(doc[0].to() == "Mark McGwire"); + YAML_ASSERT(doc[1].to() == "Sammy Sosa"); + YAML_ASSERT(doc[2].to() == "Ken Griffey"); return true; } @@ -71,9 +71,9 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); - YAML_ASSERT(doc["hr"] == "65"); - YAML_ASSERT(doc["avg"] == "0.278"); - YAML_ASSERT(doc["rbi"] == "147"); + YAML_ASSERT(doc["hr"].to() == "65"); + YAML_ASSERT(doc["avg"].to() == "0.278"); + YAML_ASSERT(doc["rbi"].to() == "147"); return true; } @@ -92,13 +92,13 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); YAML_ASSERT(doc["american"].size() == 3); - YAML_ASSERT(doc["american"][0] == "Boston Red Sox"); - YAML_ASSERT(doc["american"][1] == "Detroit Tigers"); - YAML_ASSERT(doc["american"][2] == "New York Yankees"); + YAML_ASSERT(doc["american"][0].to() == "Boston Red Sox"); + YAML_ASSERT(doc["american"][1].to() == "Detroit Tigers"); + YAML_ASSERT(doc["american"][2].to() == "New York Yankees"); YAML_ASSERT(doc["national"].size() == 3); - YAML_ASSERT(doc["national"][0] == "New York Mets"); - YAML_ASSERT(doc["national"][1] == "Chicago Cubs"); - YAML_ASSERT(doc["national"][2] == "Atlanta Braves"); + YAML_ASSERT(doc["national"][0].to() == "New York Mets"); + YAML_ASSERT(doc["national"][1].to() == "Chicago Cubs"); + YAML_ASSERT(doc["national"][2].to() == "Atlanta Braves"); return true; } @@ -118,13 +118,13 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); YAML_ASSERT(doc[0].size() == 3); - YAML_ASSERT(doc[0]["name"] == "Mark McGwire"); - YAML_ASSERT(doc[0]["hr"] == "65"); - YAML_ASSERT(doc[0]["avg"] == "0.278"); + YAML_ASSERT(doc[0]["name"].to() == "Mark McGwire"); + YAML_ASSERT(doc[0]["hr"].to() == "65"); + YAML_ASSERT(doc[0]["avg"].to() == "0.278"); YAML_ASSERT(doc[1].size() == 3); - YAML_ASSERT(doc[1]["name"] == "Sammy Sosa"); - YAML_ASSERT(doc[1]["hr"] == "63"); - YAML_ASSERT(doc[1]["avg"] == "0.288"); + YAML_ASSERT(doc[1]["name"].to() == "Sammy Sosa"); + YAML_ASSERT(doc[1]["hr"].to() == "63"); + YAML_ASSERT(doc[1]["avg"].to() == "0.288"); return true; } @@ -139,17 +139,17 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); YAML_ASSERT(doc[0].size() == 3); - YAML_ASSERT(doc[0][0] == "name"); - YAML_ASSERT(doc[0][1] == "hr"); - YAML_ASSERT(doc[0][2] == "avg"); + YAML_ASSERT(doc[0][0].to() == "name"); + YAML_ASSERT(doc[0][1].to() == "hr"); + YAML_ASSERT(doc[0][2].to() == "avg"); YAML_ASSERT(doc[1].size() == 3); - YAML_ASSERT(doc[1][0] == "Mark McGwire"); - YAML_ASSERT(doc[1][1] == "65"); - YAML_ASSERT(doc[1][2] == "0.278"); + YAML_ASSERT(doc[1][0].to() == "Mark McGwire"); + YAML_ASSERT(doc[1][1].to() == "65"); + YAML_ASSERT(doc[1][2].to() == "0.278"); YAML_ASSERT(doc[2].size() == 3); - YAML_ASSERT(doc[2][0] == "Sammy Sosa"); - YAML_ASSERT(doc[2][1] == "63"); - YAML_ASSERT(doc[2][2] == "0.288"); + YAML_ASSERT(doc[2][0].to() == "Sammy Sosa"); + YAML_ASSERT(doc[2][1].to() == "63"); + YAML_ASSERT(doc[2][2].to() == "0.288"); return true; } @@ -166,11 +166,11 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); YAML_ASSERT(doc["Mark McGwire"].size() == 2); - YAML_ASSERT(doc["Mark McGwire"]["hr"] == "65"); - YAML_ASSERT(doc["Mark McGwire"]["avg"] == "0.278"); + YAML_ASSERT(doc["Mark McGwire"]["hr"].to() == "65"); + YAML_ASSERT(doc["Mark McGwire"]["avg"].to() == "0.278"); YAML_ASSERT(doc["Sammy Sosa"].size() == 2); - YAML_ASSERT(doc["Sammy Sosa"]["hr"] == "63"); - YAML_ASSERT(doc["Sammy Sosa"]["avg"] == "0.288"); + YAML_ASSERT(doc["Sammy Sosa"]["hr"].to() == "63"); + YAML_ASSERT(doc["Sammy Sosa"]["avg"].to() == "0.288"); return true; } @@ -191,14 +191,14 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); - YAML_ASSERT(doc[0] == "Mark McGwire"); - YAML_ASSERT(doc[1] == "Sammy Sosa"); - YAML_ASSERT(doc[2] == "Ken Griffey"); + YAML_ASSERT(doc[0].to() == "Mark McGwire"); + YAML_ASSERT(doc[1].to() == "Sammy Sosa"); + YAML_ASSERT(doc[2].to() == "Ken Griffey"); PARSE_NEXT(doc); YAML_ASSERT(doc.size() == 2); - YAML_ASSERT(doc[0] == "Chicago Cubs"); - YAML_ASSERT(doc[1] == "St Louis Cardinals"); + YAML_ASSERT(doc[0].to() == "Chicago Cubs"); + YAML_ASSERT(doc[1].to() == "St Louis Cardinals"); return true; } @@ -219,15 +219,15 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); - YAML_ASSERT(doc["time"] == "20:03:20"); - YAML_ASSERT(doc["player"] == "Sammy Sosa"); - YAML_ASSERT(doc["action"] == "strike (miss)"); + YAML_ASSERT(doc["time"].to() == "20:03:20"); + YAML_ASSERT(doc["player"].to() == "Sammy Sosa"); + YAML_ASSERT(doc["action"].to() == "strike (miss)"); PARSE_NEXT(doc); YAML_ASSERT(doc.size() == 3); - YAML_ASSERT(doc["time"] == "20:03:47"); - YAML_ASSERT(doc["player"] == "Sammy Sosa"); - YAML_ASSERT(doc["action"] == "grand slam"); + YAML_ASSERT(doc["time"].to() == "20:03:47"); + YAML_ASSERT(doc["player"].to() == "Sammy Sosa"); + YAML_ASSERT(doc["action"].to() == "grand slam"); return true; } @@ -247,11 +247,11 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); YAML_ASSERT(doc["hr"].size() == 2); - YAML_ASSERT(doc["hr"][0] == "Mark McGwire"); - YAML_ASSERT(doc["hr"][1] == "Sammy Sosa"); + YAML_ASSERT(doc["hr"][0].to() == "Mark McGwire"); + YAML_ASSERT(doc["hr"][1].to() == "Sammy Sosa"); YAML_ASSERT(doc["rbi"].size() == 2); - YAML_ASSERT(doc["rbi"][0] == "Sammy Sosa"); - YAML_ASSERT(doc["rbi"][1] == "Ken Griffey"); + YAML_ASSERT(doc["rbi"][0].to() == "Sammy Sosa"); + YAML_ASSERT(doc["rbi"][1].to() == "Ken Griffey"); return true; } @@ -271,11 +271,11 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); YAML_ASSERT(doc["hr"].size() == 2); - YAML_ASSERT(doc["hr"][0] == "Mark McGwire"); - YAML_ASSERT(doc["hr"][1] == "Sammy Sosa"); + YAML_ASSERT(doc["hr"][0].to() == "Mark McGwire"); + YAML_ASSERT(doc["hr"][1].to() == "Sammy Sosa"); YAML_ASSERT(doc["rbi"].size() == 2); - YAML_ASSERT(doc["rbi"][0] == "Sammy Sosa"); - YAML_ASSERT(doc["rbi"][1] == "Ken Griffey"); + YAML_ASSERT(doc["rbi"][0].to() == "Sammy Sosa"); + YAML_ASSERT(doc["rbi"][1].to() == "Ken Griffey"); return true; } @@ -311,11 +311,11 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); YAML_ASSERT(doc[Pair("Detroit Tigers", "Chicago cubs")].size() == 1); - YAML_ASSERT(doc[Pair("Detroit Tigers", "Chicago cubs")][0] == "2001-07-23"); + YAML_ASSERT(doc[Pair("Detroit Tigers", "Chicago cubs")][0].to() == "2001-07-23"); YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")].size() == 3); - YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")][0] == "2001-07-02"); - YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")][1] == "2001-08-12"); - YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")][2] == "2001-08-14"); + YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")][0].to() == "2001-07-02"); + YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")][1].to() == "2001-08-12"); + YAML_ASSERT(doc[Pair("New York Yankees", "Atlanta Braves")][2].to() == "2001-08-14"); return true; } @@ -335,14 +335,14 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); YAML_ASSERT(doc[0].size() == 2); - YAML_ASSERT(doc[0]["item"] == "Super Hoop"); - YAML_ASSERT(doc[0]["quantity"] == 1); + YAML_ASSERT(doc[0]["item"].to() == "Super Hoop"); + YAML_ASSERT(doc[0]["quantity"].to() == 1); YAML_ASSERT(doc[1].size() == 2); - YAML_ASSERT(doc[1]["item"] == "Basketball"); - YAML_ASSERT(doc[1]["quantity"] == 4); + YAML_ASSERT(doc[1]["item"].to() == "Basketball"); + YAML_ASSERT(doc[1]["quantity"].to() == 4); YAML_ASSERT(doc[2].size() == 2); - YAML_ASSERT(doc[2]["item"] == "Big Shoes"); - YAML_ASSERT(doc[2]["quantity"] == 1); + YAML_ASSERT(doc[2]["item"].to() == "Big Shoes"); + YAML_ASSERT(doc[2]["quantity"].to() == 1); return true; } @@ -356,7 +356,7 @@ namespace Test { " // || ||__"; PARSE(doc, input); - YAML_ASSERT(doc == + YAML_ASSERT(doc.to() == "\\//||\\/||\n" "// || ||__"); return true; @@ -372,7 +372,7 @@ namespace Test { " by a knee injury."; PARSE(doc, input); - YAML_ASSERT(doc == "Mark McGwire's year was crippled by a knee injury."); + YAML_ASSERT(doc.to() == "Mark McGwire's year was crippled by a knee injury."); return true; } @@ -390,7 +390,7 @@ namespace Test { " What a year!"; PARSE(doc, input); - YAML_ASSERT(doc == + YAML_ASSERT(doc.to() == "Sammy Sosa completed another fine season with great stats.\n\n" " 63 Home Runs\n" " 0.288 Batting Average\n\n" @@ -412,9 +412,9 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); - YAML_ASSERT(doc["name"] == "Mark McGwire"); - YAML_ASSERT(doc["accomplishment"] == "Mark set a major league home run record in 1998.\n"); - YAML_ASSERT(doc["stats"] == "65 Home Runs\n0.278 Batting Average\n"); + YAML_ASSERT(doc["name"].to() == "Mark McGwire"); + YAML_ASSERT(doc["accomplishment"].to() == "Mark set a major league home run record in 1998.\n"); + YAML_ASSERT(doc["stats"].to() == "65 Home Runs\n0.278 Batting Average\n"); return true; } @@ -432,12 +432,12 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 6); - YAML_ASSERT(doc["unicode"] == "Sosa did fine.\xe2\x98\xba"); - YAML_ASSERT(doc["control"] == "\b1998\t1999\t2000\n"); - YAML_ASSERT(doc["hex esc"] == "\x0d\x0a is \r\n"); - YAML_ASSERT(doc["single"] == "\"Howdy!\" he cried."); - YAML_ASSERT(doc["quoted"] == " # Not a 'comment'."); - YAML_ASSERT(doc["tie-fighter"] == "|\\-*-/|"); + YAML_ASSERT(doc["unicode"].to() == "Sosa did fine.\xe2\x98\xba"); + YAML_ASSERT(doc["control"].to() == "\b1998\t1999\t2000\n"); + YAML_ASSERT(doc["hex esc"].to() == "\x0d\x0a is \r\n"); + YAML_ASSERT(doc["single"].to() == "\"Howdy!\" he cried."); + YAML_ASSERT(doc["quoted"].to() == " # Not a 'comment'."); + YAML_ASSERT(doc["tie-fighter"].to() == "|\\-*-/|"); return true; } @@ -454,8 +454,8 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); - YAML_ASSERT(doc["plain"] == "This unquoted scalar spans many lines."); - YAML_ASSERT(doc["quoted"] == "So does this quoted scalar.\n"); + YAML_ASSERT(doc["plain"].to() == "This unquoted scalar spans many lines."); + YAML_ASSERT(doc["quoted"].to() == "So does this quoted scalar.\n"); return true; } @@ -482,16 +482,16 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); YAML_ASSERT(doc["not-date"].Tag() == "tag:yaml.org,2002:str"); - YAML_ASSERT(doc["not-date"] == "2002-04-28"); + YAML_ASSERT(doc["not-date"].to() == "2002-04-28"); YAML_ASSERT(doc["picture"].Tag() == "tag:yaml.org,2002:binary"); - YAML_ASSERT(doc["picture"] == + YAML_ASSERT(doc["picture"].to() == "R0lGODlhDAAMAIQAAP//9/X\n" "17unp5WZmZgAAAOfn515eXv\n" "Pz7Y6OjuDg4J+fn5OTk6enp\n" "56enmleECcgggoBADs=\n" ); YAML_ASSERT(doc["application specific tag"].Tag() == "!something"); - YAML_ASSERT(doc["application specific tag"] == + YAML_ASSERT(doc["application specific tag"].to() == "The semantics of the tag\n" "above may be different for\n" "different documents." @@ -524,24 +524,24 @@ namespace Test { YAML_ASSERT(doc[0].Tag() == "tag:clarkevans.com,2002:circle"); YAML_ASSERT(doc[0].size() == 2); YAML_ASSERT(doc[0]["center"].size() == 2); - YAML_ASSERT(doc[0]["center"]["x"] == 73); - YAML_ASSERT(doc[0]["center"]["y"] == 129); - YAML_ASSERT(doc[0]["radius"] == 7); + YAML_ASSERT(doc[0]["center"]["x"].to() == 73); + YAML_ASSERT(doc[0]["center"]["y"].to() == 129); + YAML_ASSERT(doc[0]["radius"].to() == 7); YAML_ASSERT(doc[1].Tag() == "tag:clarkevans.com,2002:line"); YAML_ASSERT(doc[1].size() == 2); YAML_ASSERT(doc[1]["start"].size() == 2); - YAML_ASSERT(doc[1]["start"]["x"] == 73); - YAML_ASSERT(doc[1]["start"]["y"] == 129); + YAML_ASSERT(doc[1]["start"]["x"].to() == 73); + YAML_ASSERT(doc[1]["start"]["y"].to() == 129); YAML_ASSERT(doc[1]["finish"].size() == 2); - YAML_ASSERT(doc[1]["finish"]["x"] == 89); - YAML_ASSERT(doc[1]["finish"]["y"] == 102); + YAML_ASSERT(doc[1]["finish"]["x"].to() == 89); + YAML_ASSERT(doc[1]["finish"]["y"].to() == 102); YAML_ASSERT(doc[2].Tag() == "tag:clarkevans.com,2002:label"); YAML_ASSERT(doc[2].size() == 3); YAML_ASSERT(doc[2]["start"].size() == 2); - YAML_ASSERT(doc[2]["start"]["x"] == 73); - YAML_ASSERT(doc[2]["start"]["y"] == 129); - YAML_ASSERT(doc[2]["color"] == "0xFFEEBB"); - YAML_ASSERT(doc[2]["text"] == "Pretty vector drawing."); + YAML_ASSERT(doc[2]["start"]["x"].to() == 73); + YAML_ASSERT(doc[2]["start"]["y"].to() == 129); + YAML_ASSERT(doc[2]["color"].to() == "0xFFEEBB"); + YAML_ASSERT(doc[2]["text"].to() == "Pretty vector drawing."); return true; } @@ -582,11 +582,11 @@ namespace Test { YAML_ASSERT(doc.Tag() == "tag:yaml.org,2002:omap"); YAML_ASSERT(doc.size() == 3); YAML_ASSERT(doc[0].size() == 1); - YAML_ASSERT(doc[0]["Mark McGwire"] == 65); + YAML_ASSERT(doc[0]["Mark McGwire"].to() == 65); YAML_ASSERT(doc[1].size() == 1); - YAML_ASSERT(doc[1]["Sammy Sosa"] == 63); + YAML_ASSERT(doc[1]["Sammy Sosa"].to() == 63); YAML_ASSERT(doc[2].size() == 1); - YAML_ASSERT(doc[2]["Ken Griffey"] == 58); + YAML_ASSERT(doc[2]["Ken Griffey"].to() == 58); return true; } @@ -627,38 +627,38 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.Tag() == "tag:clarkevans.com,2002:invoice"); YAML_ASSERT(doc.size() == 8); - YAML_ASSERT(doc["invoice"] == 34843); - YAML_ASSERT(doc["date"] == "2001-01-23"); + YAML_ASSERT(doc["invoice"].to() == 34843); + YAML_ASSERT(doc["date"].to() == "2001-01-23"); YAML_ASSERT(doc["bill-to"].size() == 3); - YAML_ASSERT(doc["bill-to"]["given"] == "Chris"); - YAML_ASSERT(doc["bill-to"]["family"] == "Dumars"); + YAML_ASSERT(doc["bill-to"]["given"].to() == "Chris"); + YAML_ASSERT(doc["bill-to"]["family"].to() == "Dumars"); YAML_ASSERT(doc["bill-to"]["address"].size() == 4); - YAML_ASSERT(doc["bill-to"]["address"]["lines"] == "458 Walkman Dr.\nSuite #292\n"); - YAML_ASSERT(doc["bill-to"]["address"]["city"] == "Royal Oak"); - YAML_ASSERT(doc["bill-to"]["address"]["state"] == "MI"); - YAML_ASSERT(doc["bill-to"]["address"]["postal"] == "48046"); + YAML_ASSERT(doc["bill-to"]["address"]["lines"].to() == "458 Walkman Dr.\nSuite #292\n"); + YAML_ASSERT(doc["bill-to"]["address"]["city"].to() == "Royal Oak"); + YAML_ASSERT(doc["bill-to"]["address"]["state"].to() == "MI"); + YAML_ASSERT(doc["bill-to"]["address"]["postal"].to() == "48046"); YAML_ASSERT(doc["ship-to"].size() == 3); - YAML_ASSERT(doc["ship-to"]["given"] == "Chris"); - YAML_ASSERT(doc["ship-to"]["family"] == "Dumars"); + YAML_ASSERT(doc["ship-to"]["given"].to() == "Chris"); + YAML_ASSERT(doc["ship-to"]["family"].to() == "Dumars"); YAML_ASSERT(doc["ship-to"]["address"].size() == 4); - YAML_ASSERT(doc["ship-to"]["address"]["lines"] == "458 Walkman Dr.\nSuite #292\n"); - YAML_ASSERT(doc["ship-to"]["address"]["city"] == "Royal Oak"); - YAML_ASSERT(doc["ship-to"]["address"]["state"] == "MI"); - YAML_ASSERT(doc["ship-to"]["address"]["postal"] == "48046"); + YAML_ASSERT(doc["ship-to"]["address"]["lines"].to() == "458 Walkman Dr.\nSuite #292\n"); + YAML_ASSERT(doc["ship-to"]["address"]["city"].to() == "Royal Oak"); + YAML_ASSERT(doc["ship-to"]["address"]["state"].to() == "MI"); + YAML_ASSERT(doc["ship-to"]["address"]["postal"].to() == "48046"); YAML_ASSERT(doc["product"].size() == 2); YAML_ASSERT(doc["product"][0].size() == 4); - YAML_ASSERT(doc["product"][0]["sku"] == "BL394D"); - YAML_ASSERT(doc["product"][0]["quantity"] == 4); - YAML_ASSERT(doc["product"][0]["description"] == "Basketball"); - YAML_ASSERT(doc["product"][0]["price"] == "450.00"); + YAML_ASSERT(doc["product"][0]["sku"].to() == "BL394D"); + YAML_ASSERT(doc["product"][0]["quantity"].to() == 4); + YAML_ASSERT(doc["product"][0]["description"].to() == "Basketball"); + YAML_ASSERT(doc["product"][0]["price"].to() == "450.00"); YAML_ASSERT(doc["product"][1].size() == 4); - YAML_ASSERT(doc["product"][1]["sku"] == "BL4438H"); - YAML_ASSERT(doc["product"][1]["quantity"] == 1); - YAML_ASSERT(doc["product"][1]["description"] == "Super Hoop"); - YAML_ASSERT(doc["product"][1]["price"] == "2392.00"); - YAML_ASSERT(doc["tax"] == "251.42"); - YAML_ASSERT(doc["total"] == "4443.52"); - YAML_ASSERT(doc["comments"] == "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338."); + YAML_ASSERT(doc["product"][1]["sku"].to() == "BL4438H"); + YAML_ASSERT(doc["product"][1]["quantity"].to() == 1); + YAML_ASSERT(doc["product"][1]["description"].to() == "Super Hoop"); + YAML_ASSERT(doc["product"][1]["price"].to() == "2392.00"); + YAML_ASSERT(doc["tax"].to() == "251.42"); + YAML_ASSERT(doc["total"].to() == "4443.52"); + YAML_ASSERT(doc["comments"].to() == "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338."); return true; } @@ -695,30 +695,30 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); - YAML_ASSERT(doc["Time"] == "2001-11-23 15:01:42 -5"); - YAML_ASSERT(doc["User"] == "ed"); - YAML_ASSERT(doc["Warning"] == "This is an error message for the log file"); + YAML_ASSERT(doc["Time"].to() == "2001-11-23 15:01:42 -5"); + YAML_ASSERT(doc["User"].to() == "ed"); + YAML_ASSERT(doc["Warning"].to() == "This is an error message for the log file"); PARSE_NEXT(doc); YAML_ASSERT(doc.size() == 3); - YAML_ASSERT(doc["Time"] == "2001-11-23 15:02:31 -5"); - YAML_ASSERT(doc["User"] == "ed"); - YAML_ASSERT(doc["Warning"] == "A slightly different error message."); + YAML_ASSERT(doc["Time"].to() == "2001-11-23 15:02:31 -5"); + YAML_ASSERT(doc["User"].to() == "ed"); + YAML_ASSERT(doc["Warning"].to() == "A slightly different error message."); PARSE_NEXT(doc); YAML_ASSERT(doc.size() == 4); - YAML_ASSERT(doc["Date"] == "2001-11-23 15:03:17 -5"); - YAML_ASSERT(doc["User"] == "ed"); - YAML_ASSERT(doc["Fatal"] == "Unknown variable \"bar\""); + YAML_ASSERT(doc["Date"].to() == "2001-11-23 15:03:17 -5"); + YAML_ASSERT(doc["User"].to() == "ed"); + YAML_ASSERT(doc["Fatal"].to() == "Unknown variable \"bar\""); YAML_ASSERT(doc["Stack"].size() == 2); YAML_ASSERT(doc["Stack"][0].size() == 3); - YAML_ASSERT(doc["Stack"][0]["file"] == "TopClass.py"); - YAML_ASSERT(doc["Stack"][0]["line"] == "23"); - YAML_ASSERT(doc["Stack"][0]["code"] == "x = MoreObject(\"345\\n\")\n"); + YAML_ASSERT(doc["Stack"][0]["file"].to() == "TopClass.py"); + YAML_ASSERT(doc["Stack"][0]["line"].to() == "23"); + YAML_ASSERT(doc["Stack"][0]["code"].to() == "x = MoreObject(\"345\\n\")\n"); YAML_ASSERT(doc["Stack"][1].size() == 3); - YAML_ASSERT(doc["Stack"][1]["file"] == "MoreClass.py"); - YAML_ASSERT(doc["Stack"][1]["line"] == "58"); - YAML_ASSERT(doc["Stack"][1]["code"] == "foo = bar"); + YAML_ASSERT(doc["Stack"][1]["file"].to() == "MoreClass.py"); + YAML_ASSERT(doc["Stack"][1]["line"].to() == "58"); + YAML_ASSERT(doc["Stack"][1]["code"].to() == "foo = bar"); return true; } @@ -739,11 +739,11 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); YAML_ASSERT(doc["sequence"].size() == 2); - YAML_ASSERT(doc["sequence"][0] == "one"); - YAML_ASSERT(doc["sequence"][1] == "two"); + YAML_ASSERT(doc["sequence"][0].to() == "one"); + YAML_ASSERT(doc["sequence"][1].to() == "two"); YAML_ASSERT(doc["mapping"].size() == 2); - YAML_ASSERT(doc["mapping"]["sky"] == "blue"); - YAML_ASSERT(doc["mapping"]["sea"] == "green"); + YAML_ASSERT(doc["mapping"]["sky"].to() == "blue"); + YAML_ASSERT(doc["mapping"]["sea"].to() == "green"); return true; } @@ -757,11 +757,11 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); YAML_ASSERT(doc["sequence"].size() == 2); - YAML_ASSERT(doc["sequence"][0] == "one"); - YAML_ASSERT(doc["sequence"][1] == "two"); + YAML_ASSERT(doc["sequence"][0].to() == "one"); + YAML_ASSERT(doc["sequence"][1].to() == "two"); YAML_ASSERT(doc["mapping"].size() == 2); - YAML_ASSERT(doc["mapping"]["sky"] == "blue"); - YAML_ASSERT(doc["mapping"]["sea"] == "green"); + YAML_ASSERT(doc["mapping"]["sky"].to() == "blue"); + YAML_ASSERT(doc["mapping"]["sea"].to() == "green"); return true; } @@ -785,8 +785,8 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); - YAML_ASSERT(doc["anchored"] == "value"); // TODO: assert tag - YAML_ASSERT(doc["alias"] == "value"); + YAML_ASSERT(doc["anchored"].to() == "value"); // TODO: assert tag + YAML_ASSERT(doc["alias"].to() == "value"); return true; } @@ -803,8 +803,8 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); - YAML_ASSERT(doc["literal"] == "some\ntext\n"); - YAML_ASSERT(doc["folded"] == "some text\n"); + YAML_ASSERT(doc["literal"].to() == "some\ntext\n"); + YAML_ASSERT(doc["folded"].to() == "some text\n"); return true; } @@ -817,8 +817,8 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); - YAML_ASSERT(doc["single"] == "text"); - YAML_ASSERT(doc["double"] == "text"); + YAML_ASSERT(doc["single"].to() == "text"); + YAML_ASSERT(doc["double"].to() == "text"); return true; } @@ -834,7 +834,7 @@ namespace Test { " Line break (glyphed)\n"; PARSE(doc, input); - YAML_ASSERT(doc == "Line break (no glyph)\nLine break (glyphed)\n"); + YAML_ASSERT(doc.to() == "Line break (no glyph)\nLine break (glyphed)\n"); return true; } @@ -851,8 +851,8 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); - YAML_ASSERT(doc["quoted"] == "Quoted\t"); - YAML_ASSERT(doc["block"] == + YAML_ASSERT(doc["quoted"].to() == "Quoted\t"); + YAML_ASSERT(doc["block"].to() == "void main() {\n" "\tprintf(\"Hello, world!\\n\");\n" "}"); @@ -870,7 +870,7 @@ namespace Test { "\\x41 \\u0041 \\U00000041\""; PARSE(doc, input); - YAML_ASSERT(doc == "Fun with \x5C \x22 \x07 \x08 \x1B \x0C \x0A \x0D \x09 \x0B " + std::string("\x00", 1) + " \x20 \xA0 \x85 \xe2\x80\xa8 \xe2\x80\xa9 A A A"); + YAML_ASSERT(doc.to() == "Fun with \x5C \x22 \x07 \x08 \x1B \x0C \x0A \x0D \x09 \x0B " + std::string("\x00", 1) + " \x20 \xA0 \x85 \xe2\x80\xa8 \xe2\x80\xa9 A A A"); return true; } @@ -915,11 +915,11 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 1); YAML_ASSERT(doc["Not indented"].size() == 2); - YAML_ASSERT(doc["Not indented"]["By one space"] == "By four\n spaces\n"); + YAML_ASSERT(doc["Not indented"]["By one space"].to() == "By four\n spaces\n"); YAML_ASSERT(doc["Not indented"]["Flow style"].size() == 3); - YAML_ASSERT(doc["Not indented"]["Flow style"][0] == "By two"); - YAML_ASSERT(doc["Not indented"]["Flow style"][1] == "Also by two"); - YAML_ASSERT(doc["Not indented"]["Flow style"][2] == "Still by two"); + YAML_ASSERT(doc["Not indented"]["Flow style"][0].to() == "By two"); + YAML_ASSERT(doc["Not indented"]["Flow style"][1].to() == "Also by two"); + YAML_ASSERT(doc["Not indented"]["Flow style"][2].to() == "Still by two"); return true; } @@ -935,10 +935,10 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 1); YAML_ASSERT(doc["a"].size() == 2); - YAML_ASSERT(doc["a"][0] == "b"); + YAML_ASSERT(doc["a"][0].to() == "b"); YAML_ASSERT(doc["a"][1].size() == 2); - YAML_ASSERT(doc["a"][1][0] == "c"); - YAML_ASSERT(doc["a"][1][1] == "d"); + YAML_ASSERT(doc["a"][1][0].to() == "c"); + YAML_ASSERT(doc["a"][1][1].to() == "d"); return true; } @@ -953,10 +953,10 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); YAML_ASSERT(doc[0].size() == 1); - YAML_ASSERT(doc[0]["foo"] == "bar"); + YAML_ASSERT(doc[0]["foo"].to() == "bar"); YAML_ASSERT(doc[1].size() == 2); - YAML_ASSERT(doc[1][0] == "baz"); - YAML_ASSERT(doc[1][1] == "baz"); + YAML_ASSERT(doc[1][0].to() == "baz"); + YAML_ASSERT(doc[1][1].to() == "baz"); return true; } @@ -974,9 +974,9 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); - YAML_ASSERT(doc["plain"] == "text lines"); - YAML_ASSERT(doc["quoted"] == "text lines"); - YAML_ASSERT(doc["block"] == "text\n \tlines\n"); + YAML_ASSERT(doc["plain"].to() == "text lines"); + YAML_ASSERT(doc["quoted"].to() == "text lines"); + YAML_ASSERT(doc["block"].to() == "text\n \tlines\n"); return true; } @@ -994,8 +994,8 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); - YAML_ASSERT(doc["Folding"] == "Empty line\nas a line feed"); - YAML_ASSERT(doc["Chomping"] == "Clipped empty lines\n"); + YAML_ASSERT(doc["Folding"].to() == "Empty line\nas a line feed"); + YAML_ASSERT(doc["Chomping"].to() == "Clipped empty lines\n"); return true; } @@ -1012,7 +1012,7 @@ namespace Test { " space"; PARSE(doc, input); - YAML_ASSERT(doc == "trimmed\n\n\nas space"); + YAML_ASSERT(doc.to() == "trimmed\n\n\nas space"); return true; } @@ -1028,7 +1028,7 @@ namespace Test { " baz\n"; PARSE(doc, input); - YAML_ASSERT(doc == "foo \n\n\t bar\n\nbaz\n"); + YAML_ASSERT(doc.to() == "foo \n\n\t bar\n\nbaz\n"); return true; } @@ -1045,7 +1045,7 @@ namespace Test { "\""; PARSE(doc, input); - YAML_ASSERT(doc == " foo\nbar\nbaz "); + YAML_ASSERT(doc.to() == " foo\nbar\nbaz "); return true; } @@ -1058,7 +1058,7 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 1); - YAML_ASSERT(doc["key"] == "value"); + YAML_ASSERT(doc["key"].to() == "value"); return true; } @@ -1086,7 +1086,7 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 1); - YAML_ASSERT(doc["key"] == "value"); + YAML_ASSERT(doc["key"].to() == "value"); return true; } @@ -1102,8 +1102,8 @@ namespace Test { void operator >> (const YAML::Node& node, StringMap& m) { m._.clear(); for(YAML::Iterator it=node.begin();it!=node.end();++it) { - std::string key = it.first(); - std::string value = it.second(); + std::string key = it.first().to(); + std::string value = it.second().to(); m._[key] = value; } } @@ -1126,8 +1126,8 @@ namespace Test { key["last"] = "Sosa"; YAML_ASSERT(doc.size() == 1); YAML_ASSERT(doc[key].size() == 2); - YAML_ASSERT(doc[key]["hr"] == 65); - YAML_ASSERT(doc[key]["avg"] == "0.278"); + YAML_ASSERT(doc[key]["hr"].to() == 65); + YAML_ASSERT(doc[key]["avg"].to() == "0.278"); return true; } @@ -1186,7 +1186,7 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.Tag() == "tag:yaml.org,2002:str"); - YAML_ASSERT(doc == "foo"); + YAML_ASSERT(doc.to() == "foo"); return true; } @@ -1224,11 +1224,11 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.Tag() == "!foo"); - YAML_ASSERT(doc == "bar"); + YAML_ASSERT(doc.to() == "bar"); PARSE_NEXT(doc); YAML_ASSERT(doc.Tag() == "tag:example.com,2000:app/foo"); - YAML_ASSERT(doc == "bar"); + YAML_ASSERT(doc.to() == "bar"); return true; } @@ -1242,7 +1242,7 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.Tag() == "tag:example.com,2000:app/int"); - YAML_ASSERT(doc == "1 - 3"); + YAML_ASSERT(doc.to() == "1 - 3"); return true; } @@ -1256,7 +1256,7 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.Tag() == "tag:example.com,2000:app/foo"); - YAML_ASSERT(doc == "bar"); + YAML_ASSERT(doc.to() == "bar"); return true; } @@ -1274,11 +1274,11 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.Tag() == "!my-light"); - YAML_ASSERT(doc == "fluorescent"); + YAML_ASSERT(doc.to() == "fluorescent"); PARSE_NEXT(doc); YAML_ASSERT(doc.Tag() == "!my-light"); - YAML_ASSERT(doc == "green"); + YAML_ASSERT(doc.to() == "green"); return true; } @@ -1293,7 +1293,7 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 1); YAML_ASSERT(doc[0].Tag() == "tag:example.com,2000:app/foo"); - YAML_ASSERT(doc[0] == "bar"); + YAML_ASSERT(doc[0].to() == "bar"); return true; } @@ -1308,12 +1308,12 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); for(YAML::Iterator it=doc.begin();it!=doc.end();++it) { - if(it.first() == "foo") { + if(it.first().to() == "foo") { YAML_ASSERT(it.first().Tag() == "tag:yaml.org,2002:str"); YAML_ASSERT(it.second().Tag() == "tag:yaml.org,2002:str"); - YAML_ASSERT(it.second() == "bar"); - } else if(it.first() == "baz") { - YAML_ASSERT(it.second() == "foo"); + YAML_ASSERT(it.second().to() == "bar"); + } else if(it.first().to() == "baz") { + YAML_ASSERT(it.second().to() == "foo"); } else return " unknown key"; } @@ -1332,9 +1332,9 @@ namespace Test { YAML_ASSERT(doc.size() == 1); for(YAML::Iterator it=doc.begin();it!=doc.end();++it) { YAML_ASSERT(it.first().Tag() == "tag:yaml.org,2002:str"); - YAML_ASSERT(it.first() == "foo"); + YAML_ASSERT(it.first().to() == "foo"); YAML_ASSERT(it.second().Tag() == "!bar"); - YAML_ASSERT(it.second() == "baz"); + YAML_ASSERT(it.second().to() == "baz"); } return true; } @@ -1363,11 +1363,11 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); YAML_ASSERT(doc[0].Tag() == "!local"); - YAML_ASSERT(doc[0] == "foo"); + YAML_ASSERT(doc[0].to() == "foo"); YAML_ASSERT(doc[1].Tag() == "tag:yaml.org,2002:str"); - YAML_ASSERT(doc[1] == "bar"); + YAML_ASSERT(doc[1].to() == "bar"); YAML_ASSERT(doc[2].Tag() == "tag:example.com,2000:app/tag%21"); - YAML_ASSERT(doc[2] == "baz"); + YAML_ASSERT(doc[2].to() == "baz"); return true; } @@ -1411,9 +1411,9 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); - YAML_ASSERT(doc[0] == "12"); // TODO: check tags. How? - YAML_ASSERT(doc[1] == 12); - YAML_ASSERT(doc[2] == "12"); + YAML_ASSERT(doc[0].to() == "12"); // TODO: check tags. How? + YAML_ASSERT(doc[1].to() == 12); + YAML_ASSERT(doc[2].to() == "12"); return true; } @@ -1426,8 +1426,8 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); - YAML_ASSERT(doc["First occurrence"] == "Value"); - YAML_ASSERT(doc["Second occurrence"] == "Value"); + YAML_ASSERT(doc["First occurrence"].to() == "Value"); + YAML_ASSERT(doc["Second occurrence"].to() == "Value"); return true; } @@ -1442,10 +1442,10 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 4); - YAML_ASSERT(doc["First occurrence"] == "Foo"); - YAML_ASSERT(doc["Second occurrence"] == "Foo"); - YAML_ASSERT(doc["Override anchor"] == "Bar"); - YAML_ASSERT(doc["Reuse anchor"] == "Bar"); + YAML_ASSERT(doc["First occurrence"].to() == "Foo"); + YAML_ASSERT(doc["Second occurrence"].to() == "Foo"); + YAML_ASSERT(doc["Override anchor"].to() == "Bar"); + YAML_ASSERT(doc["Reuse anchor"].to() == "Bar"); return true; } @@ -1461,12 +1461,12 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); for(YAML::Iterator it=doc.begin();it!=doc.end();++it) { - if(it.first() == "foo") { + if(it.first().to() == "foo") { YAML_ASSERT(it.second().Tag() == "tag:yaml.org,2002:str"); - YAML_ASSERT(it.second() == ""); - } else if(it.first() == "") { + YAML_ASSERT(it.second().to() == ""); + } else if(it.first().to() == "") { YAML_ASSERT(it.first().Tag() == "tag:yaml.org,2002:str"); - YAML_ASSERT(it.second() == "bar"); + YAML_ASSERT(it.second().to() == "bar"); } else return " unexpected key"; } @@ -1485,7 +1485,7 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); YAML_ASSERT(IsNull(doc["foo"])); - YAML_ASSERT(doc[YAML::Null] == "bar"); + YAML_ASSERT(doc[YAML::Null].to() == "bar"); return true; } @@ -1501,7 +1501,7 @@ namespace Test { YAML_ASSERT(doc.size() == 1); YAML_ASSERT(doc["implicit block key"].size() == 1); YAML_ASSERT(doc["implicit block key"][0].size() == 1); - YAML_ASSERT(doc["implicit block key"][0]["implicit flow key"] == "value"); + YAML_ASSERT(doc["implicit block key"][0]["implicit flow key"].to() == "value"); return true; } @@ -1516,7 +1516,7 @@ namespace Test { " \\ \tnon-content\""; PARSE(doc, input); - YAML_ASSERT(doc == "folded to a space,\nto a line feed, or \t \tnon-content"); + YAML_ASSERT(doc.to() == "folded to a space,\nto a line feed, or \t \tnon-content"); return true; } @@ -1530,7 +1530,7 @@ namespace Test { "\t3rd non-empty \""; PARSE(doc, input); - YAML_ASSERT(doc == " 1st non-empty\n2nd non-empty 3rd non-empty "); + YAML_ASSERT(doc.to() == " 1st non-empty\n2nd non-empty 3rd non-empty "); return true; } @@ -1540,7 +1540,7 @@ namespace Test { std::string input = " 'here''s to \"quotes\"'"; PARSE(doc, input); - YAML_ASSERT(doc == "here's to \"quotes\""); + YAML_ASSERT(doc.to() == "here's to \"quotes\""); return true; } @@ -1556,7 +1556,7 @@ namespace Test { YAML_ASSERT(doc.size() == 1); YAML_ASSERT(doc["implicit block key"].size() == 1); YAML_ASSERT(doc["implicit block key"][0].size() == 1); - YAML_ASSERT(doc["implicit block key"][0]["implicit flow key"] == "value"); + YAML_ASSERT(doc["implicit block key"][0]["implicit flow key"].to() == "value"); return true; } @@ -1570,7 +1570,7 @@ namespace Test { "\t3rd non-empty '"; PARSE(doc, input); - YAML_ASSERT(doc == " 1st non-empty\n2nd non-empty 3rd non-empty "); + YAML_ASSERT(doc.to() == " 1st non-empty\n2nd non-empty 3rd non-empty "); return true; } @@ -1593,17 +1593,17 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 6); - YAML_ASSERT(doc[0] == "::vector"); - YAML_ASSERT(doc[1] == ": - ()"); - YAML_ASSERT(doc[2] == "Up, up, and away!"); - YAML_ASSERT(doc[3] == -123); - YAML_ASSERT(doc[4] == "http://example.com/foo#bar"); + YAML_ASSERT(doc[0].to() == "::vector"); + YAML_ASSERT(doc[1].to() == ": - ()"); + YAML_ASSERT(doc[2].to() == "Up, up, and away!"); + YAML_ASSERT(doc[3].to() == -123); + YAML_ASSERT(doc[4].to() == "http://example.com/foo#bar"); YAML_ASSERT(doc[5].size() == 5); - YAML_ASSERT(doc[5][0] == "::vector"); - YAML_ASSERT(doc[5][1] == ": - ()"); - YAML_ASSERT(doc[5][2] == "Up, up, and away!"); - YAML_ASSERT(doc[5][3] == -123); - YAML_ASSERT(doc[5][4] == "http://example.com/foo#bar"); + YAML_ASSERT(doc[5][0].to() == "::vector"); + YAML_ASSERT(doc[5][1].to() == ": - ()"); + YAML_ASSERT(doc[5][2].to() == "Up, up, and away!"); + YAML_ASSERT(doc[5][3].to() == -123); + YAML_ASSERT(doc[5][4].to() == "http://example.com/foo#bar"); return true; } @@ -1619,7 +1619,7 @@ namespace Test { YAML_ASSERT(doc.size() == 1); YAML_ASSERT(doc["implicit block key"].size() == 1); YAML_ASSERT(doc["implicit block key"][0].size() == 1); - YAML_ASSERT(doc["implicit block key"][0]["implicit flow key"] == "value"); + YAML_ASSERT(doc["implicit block key"][0]["implicit flow key"].to() == "value"); return true; } @@ -1633,7 +1633,7 @@ namespace Test { "\t3rd non-empty"; PARSE(doc, input); - YAML_ASSERT(doc == "1st non-empty\n2nd non-empty 3rd non-empty"); + YAML_ASSERT(doc.to() == "1st non-empty\n2nd non-empty 3rd non-empty"); return true; } @@ -1647,11 +1647,11 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); YAML_ASSERT(doc[0].size() == 2); - YAML_ASSERT(doc[0][0] == "one"); - YAML_ASSERT(doc[0][1] == "two"); + YAML_ASSERT(doc[0][0].to() == "one"); + YAML_ASSERT(doc[0][1].to() == "two"); YAML_ASSERT(doc[1].size() == 2); - YAML_ASSERT(doc[1][0] == "three"); - YAML_ASSERT(doc[1][1] == "four"); + YAML_ASSERT(doc[1][0].to() == "three"); + YAML_ASSERT(doc[1][1].to() == "four"); return true; } @@ -1670,13 +1670,13 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 5); - YAML_ASSERT(doc[0] == "double quoted"); - YAML_ASSERT(doc[1] == "single quoted"); - YAML_ASSERT(doc[2] == "plain text"); + YAML_ASSERT(doc[0].to() == "double quoted"); + YAML_ASSERT(doc[1].to() == "single quoted"); + YAML_ASSERT(doc[2].to() == "plain text"); YAML_ASSERT(doc[3].size() == 1); - YAML_ASSERT(doc[3][0] == "nested"); + YAML_ASSERT(doc[3][0].to() == "nested"); YAML_ASSERT(doc[4].size() == 1); - YAML_ASSERT(doc[4]["single"] == "pair"); + YAML_ASSERT(doc[4]["single"].to() == "pair"); return true; } @@ -1690,11 +1690,11 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); YAML_ASSERT(doc[0].size() == 2); - YAML_ASSERT(doc[0]["one"] == "two"); - YAML_ASSERT(doc[0]["three"] == "four"); + YAML_ASSERT(doc[0]["one"].to() == "two"); + YAML_ASSERT(doc[0]["three"].to() == "four"); YAML_ASSERT(doc[1].size() == 2); - YAML_ASSERT(doc[1]["five"] == "six"); - YAML_ASSERT(doc[1]["seven"] == "eight"); + YAML_ASSERT(doc[1]["five"].to() == "six"); + YAML_ASSERT(doc[1]["seven"].to() == "eight"); return true; } @@ -1710,8 +1710,8 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); - YAML_ASSERT(doc["explicit"] == "entry"); - YAML_ASSERT(doc["implicit"] == "entry"); + YAML_ASSERT(doc["explicit"].to() == "entry"); + YAML_ASSERT(doc["implicit"].to() == "entry"); YAML_ASSERT(IsNull(doc[YAML::Null])); return true; } @@ -1729,10 +1729,10 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 4); - YAML_ASSERT(doc["unquoted"] == "separate"); + YAML_ASSERT(doc["unquoted"].to() == "separate"); YAML_ASSERT(IsNull(doc["http://foo.com"])); YAML_ASSERT(IsNull(doc["omitted value"])); - YAML_ASSERT(doc[YAML::Null] == "omitted key"); + YAML_ASSERT(doc[YAML::Null].to() == "omitted key"); return true; } @@ -1748,8 +1748,8 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); - YAML_ASSERT(doc["adjacent"] == "value"); - YAML_ASSERT(doc["readable"] == "value"); + YAML_ASSERT(doc["adjacent"].to() == "value"); + YAML_ASSERT(doc["readable"].to() == "value"); YAML_ASSERT(IsNull(doc["empty"])); return true; } @@ -1765,7 +1765,7 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 1); YAML_ASSERT(doc[0].size() == 1); - YAML_ASSERT(doc[0]["foo"] == "bar"); + YAML_ASSERT(doc[0]["foo"].to() == "bar"); return true; } @@ -1781,7 +1781,7 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 1); YAML_ASSERT(doc[0].size() == 1); - YAML_ASSERT(doc[0]["foo bar"] == "baz"); + YAML_ASSERT(doc[0]["foo bar"].to() == "baz"); return true; } @@ -1797,15 +1797,15 @@ namespace Test { YAML_ASSERT(doc.size() == 3); YAML_ASSERT(doc[0].size() == 1); YAML_ASSERT(doc[0][0].size() == 1); - YAML_ASSERT(doc[0][0]["YAML"] == "separate"); + YAML_ASSERT(doc[0][0]["YAML"].to() == "separate"); YAML_ASSERT(doc[1].size() == 1); YAML_ASSERT(doc[1][0].size() == 1); - YAML_ASSERT(doc[1][0][YAML::Null] == "empty key entry"); + YAML_ASSERT(doc[1][0][YAML::Null].to() == "empty key entry"); YAML_ASSERT(doc[2].size() == 1); YAML_ASSERT(doc[2][0].size() == 1); StringMap key; key._["JSON"] = "like"; - YAML_ASSERT(doc[2][0][key] == "adjacent"); + YAML_ASSERT(doc[2][0][key].to() == "adjacent"); return true; } @@ -1840,13 +1840,13 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 5); YAML_ASSERT(doc[0].size() == 2); - YAML_ASSERT(doc[0][0] == "a"); - YAML_ASSERT(doc[0][1] == "b"); + YAML_ASSERT(doc[0][0].to() == "a"); + YAML_ASSERT(doc[0][1].to() == "b"); YAML_ASSERT(doc[1].size() == 1); - YAML_ASSERT(doc[1]["a"] == "b"); - YAML_ASSERT(doc[2] == "a"); - YAML_ASSERT(doc[3] == 'b'); - YAML_ASSERT(doc[4] == "c"); + YAML_ASSERT(doc[1]["a"].to() == "b"); + YAML_ASSERT(doc[2].to() == "a"); + YAML_ASSERT(doc[3].to() == 'b'); + YAML_ASSERT(doc[4].to() == "c"); return true; } @@ -1863,12 +1863,12 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 5); YAML_ASSERT(doc[0].Tag() == "tag:yaml.org,2002:str"); - YAML_ASSERT(doc[0] == "a"); - YAML_ASSERT(doc[1] == 'b'); - YAML_ASSERT(doc[2] == "c"); - YAML_ASSERT(doc[3] == "c"); + YAML_ASSERT(doc[0].to() == "a"); + YAML_ASSERT(doc[1].to() == 'b'); + YAML_ASSERT(doc[2].to() == "c"); + YAML_ASSERT(doc[3].to() == "c"); YAML_ASSERT(doc[4].Tag() == "tag:yaml.org,2002:str"); - YAML_ASSERT(doc[4] == ""); + YAML_ASSERT(doc[4].to() == ""); return true; } @@ -1888,10 +1888,10 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 4); - YAML_ASSERT(doc[0] == "literal\n"); - YAML_ASSERT(doc[1] == " folded\n"); - YAML_ASSERT(doc[2] == "keep\n\n"); - YAML_ASSERT(doc[3] == " strip"); + YAML_ASSERT(doc[0].to() == "literal\n"); + YAML_ASSERT(doc[1].to() == " folded\n"); + YAML_ASSERT(doc[2].to() == "keep\n\n"); + YAML_ASSERT(doc[3].to() == " strip"); return true; } @@ -1913,10 +1913,10 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 4); - YAML_ASSERT(doc[0] == "detected\n"); - YAML_ASSERT(doc[1] == "\n\n# detected\n"); - YAML_ASSERT(doc[2] == " explicit\n"); - YAML_ASSERT(doc[3] == "\t\ndetected\n"); + YAML_ASSERT(doc[0].to() == "detected\n"); + YAML_ASSERT(doc[1].to() == "\n\n# detected\n"); + YAML_ASSERT(doc[2].to() == " explicit\n"); + YAML_ASSERT(doc[3].to() == "\t\ndetected\n"); return true; } @@ -1998,9 +1998,9 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); - YAML_ASSERT(doc["strip"] == "text"); - YAML_ASSERT(doc["clip"] == "text\n"); - YAML_ASSERT(doc["keep"] == "text\n"); + YAML_ASSERT(doc["strip"].to() == "text"); + YAML_ASSERT(doc["clip"].to() == "text\n"); + YAML_ASSERT(doc["keep"].to() == "text\n"); return true; } @@ -2030,9 +2030,9 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); - YAML_ASSERT(doc["strip"] == "# text"); - YAML_ASSERT(doc["clip"] == "# text\n"); - YAML_ASSERT(doc["keep"] == "# text\n"); + YAML_ASSERT(doc["strip"].to() == "# text"); + YAML_ASSERT(doc["clip"].to() == "# text\n"); + YAML_ASSERT(doc["keep"].to() == "# text\n"); return true; } @@ -2049,9 +2049,9 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); - YAML_ASSERT(doc["strip"] == ""); - YAML_ASSERT(doc["clip"] == ""); - YAML_ASSERT(doc["keep"] == "\n"); + YAML_ASSERT(doc["strip"].to() == ""); + YAML_ASSERT(doc["clip"].to() == ""); + YAML_ASSERT(doc["keep"].to() == "\n"); return true; } @@ -2065,7 +2065,7 @@ namespace Test { "\n"; PARSE(doc, input); - YAML_ASSERT(doc == "literal\n\ttext\n"); + YAML_ASSERT(doc.to() == "literal\n\ttext\n"); return true; } @@ -2084,7 +2084,7 @@ namespace Test { " # Comment\n"; PARSE(doc, input); - YAML_ASSERT(doc == "\n\nliteral\n \n\ntext\n"); + YAML_ASSERT(doc.to() == "\n\nliteral\n \n\ntext\n"); return true; } @@ -2098,7 +2098,7 @@ namespace Test { "\n"; PARSE(doc, input); - YAML_ASSERT(doc == "folded text\n"); + YAML_ASSERT(doc.to() == "folded text\n"); return true; } @@ -2124,7 +2124,7 @@ namespace Test { "# Comment\n"; PARSE(doc, input); - YAML_ASSERT(doc == "\nfolded line\nnext line\n * bullet\n\n * list\n * lines\n\nlast line\n"); + YAML_ASSERT(doc.to() == "\nfolded line\nnext line\n * bullet\n\n * list\n * lines\n\nlast line\n"); return true; } @@ -2157,9 +2157,9 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 1); YAML_ASSERT(doc["block sequence"].size() == 2); - YAML_ASSERT(doc["block sequence"][0] == "one"); + YAML_ASSERT(doc["block sequence"][0].to() == "one"); YAML_ASSERT(doc["block sequence"][1].size() == 1); - YAML_ASSERT(doc["block sequence"][1]["two"] == "three"); + YAML_ASSERT(doc["block sequence"][1]["two"].to() == "three"); return true; } @@ -2177,12 +2177,12 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 4); YAML_ASSERT(YAML::IsNull(doc[0])); - YAML_ASSERT(doc[1] == "block node\n"); + YAML_ASSERT(doc[1].to() == "block node\n"); YAML_ASSERT(doc[2].size() == 2); - YAML_ASSERT(doc[2][0] == "one"); - YAML_ASSERT(doc[2][1] == "two"); + YAML_ASSERT(doc[2][0].to() == "one"); + YAML_ASSERT(doc[2][1].to() == "two"); YAML_ASSERT(doc[3].size() == 1); - YAML_ASSERT(doc[3]["one"] == "two"); + YAML_ASSERT(doc[3]["one"].to() == "two"); return true; } @@ -2196,7 +2196,7 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 1); YAML_ASSERT(doc["block mapping"].size() == 1); - YAML_ASSERT(doc["block mapping"]["key"] == "value"); + YAML_ASSERT(doc["block mapping"]["key"].to() == "value"); return true; } @@ -2214,8 +2214,8 @@ namespace Test { YAML_ASSERT(doc.size() == 2); YAML_ASSERT(IsNull(doc["explicit key"])); YAML_ASSERT(doc["block key\n"].size() == 2); - YAML_ASSERT(doc["block key\n"][0] == "one"); - YAML_ASSERT(doc["block key\n"][1] == "two"); + YAML_ASSERT(doc["block key\n"][0].to() == "one"); + YAML_ASSERT(doc["block key\n"][1].to() == "two"); return true; } @@ -2230,10 +2230,10 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); - YAML_ASSERT(doc["plain key"] == "in-line value"); + YAML_ASSERT(doc["plain key"].to() == "in-line value"); YAML_ASSERT(IsNull(doc[YAML::Null])); YAML_ASSERT(doc["quoted key"].size() == 1); - YAML_ASSERT(doc["quoted key"][0] == "entry"); + YAML_ASSERT(doc["quoted key"][0].to() == "entry"); return true; } @@ -2248,12 +2248,12 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); YAML_ASSERT(doc[0].size() == 1); - YAML_ASSERT(doc[0]["sun"] == "yellow"); + YAML_ASSERT(doc[0]["sun"].to() == "yellow"); YAML_ASSERT(doc[1].size() == 1); std::map key; key["earth"] = "blue"; YAML_ASSERT(doc[1][key].size() == 1); - YAML_ASSERT(doc[1][key]["moon"] == "white"); + YAML_ASSERT(doc[1][key]["moon"].to() == "white"); return true; } @@ -2270,10 +2270,10 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 3); - YAML_ASSERT(doc[0] == "flow in block"); - YAML_ASSERT(doc[1] == "Block scalar\n"); + YAML_ASSERT(doc[0].to() == "flow in block"); + YAML_ASSERT(doc[1].to() == "Block scalar\n"); YAML_ASSERT(doc[2].size() == 1); - YAML_ASSERT(doc[2]["foo"] == "bar"); + YAML_ASSERT(doc[2]["foo"].to() == "bar"); return true; } @@ -2290,8 +2290,8 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); - YAML_ASSERT(doc["literal"] == "value"); - YAML_ASSERT(doc["folded"] == "value"); + YAML_ASSERT(doc["literal"].to() == "value"); + YAML_ASSERT(doc["folded"].to() == "value"); YAML_ASSERT(doc["folded"].Tag() == "!foo"); return true; } @@ -2310,11 +2310,11 @@ namespace Test { PARSE(doc, input); YAML_ASSERT(doc.size() == 2); YAML_ASSERT(doc["sequence"].size() == 2); - YAML_ASSERT(doc["sequence"][0] == "entry"); + YAML_ASSERT(doc["sequence"][0].to() == "entry"); YAML_ASSERT(doc["sequence"][1].size() == 1); - YAML_ASSERT(doc["sequence"][1][0] == "nested"); + YAML_ASSERT(doc["sequence"][1][0].to() == "nested"); YAML_ASSERT(doc["mapping"].size() == 1); - YAML_ASSERT(doc["mapping"]["foo"] == "bar"); + YAML_ASSERT(doc["mapping"]["foo"].to() == "bar"); return true; } }