bool ObjectTemplateLoader::load(ObjectTemplate& resource, IInputStream& input) {
		String error;
		// TODO: Get rid of reinterpret_cast!
		YAML yaml;
		if (yaml.read(resource.document, input, error) == 0) {
			Error() << "YAML: " << error;
			return false;
		}
		return true;
	}
Example #2
0
ConfigNode &
ConfigNode::operator=(
  const ConfigNode &rhs)
{
  if (!rhs) {
    Node::reset(Node(YAML::NodeType::Undefined));
  } else {
    Node::reset(rhs);
  }
  path_ = rhs.path_;
  filemap_.reset(rhs.filemap_);
  return *this;
}
#include "scene/scene.h"
#include "scene/sceneLoader.h"
#include "style/material.h"
#include "style/polylineStyle.h"
#include "style/polygonStyle.h"
#include "style/style.h"

#include "yaml-cpp/yaml.h"

using namespace Tangram;
using YAML::Node;

TEST_CASE("Style with the same name as a built-in style are ignored") {
    std::shared_ptr<Platform> platform = std::make_shared<MockPlatform>();
    std::shared_ptr<Scene> scene = std::make_shared<Scene>(platform, Url());
    SceneLoader::loadStyle(platform, "polygons", Node(), scene);
    REQUIRE(scene->styles().size() == 0);

}

TEST_CASE("Correctly instantiate a style from a YAML configuration") {
    std::shared_ptr<Platform> platform = std::make_shared<MockPlatform>();
    std::shared_ptr<Scene> scene = std::make_shared<Scene>(platform, Url());

    scene->styles().emplace_back(new PolygonStyle("polygons"));
    scene->styles().emplace_back(new PolylineStyle("lines"));

    YAML::Node node = YAML::Load(R"END(
        animated: true
        texcoords: true
        base: lines
#include "scene/scene.h"
#include "style/material.h"
#include "style/style.h"
#include "style/polylineStyle.h"
#include "style/polygonStyle.h"
#include "scene/pointLight.h"

#include "platform.h"

using namespace Tangram;
using YAML::Node;

TEST_CASE("Style with the same name as a built-in style are ignored") {

    std::shared_ptr<Scene> scene = std::make_shared<Scene>();
    SceneLoader::loadStyle("polygons", Node(), scene);
    REQUIRE(scene->styles().size() == 0);

}

TEST_CASE("Correctly instantiate a style from a YAML configuration") {
    std::shared_ptr<Scene> scene = std::make_shared<Scene>();

    scene->styles().emplace_back(new PolygonStyle("polygons"));
    scene->styles().emplace_back(new PolylineStyle("lines"));

    YAML::Node node = YAML::Load(R"END(
        animated: true
        texcoords: true
        base: lines
        mix: tools