cgv
Loading...
Searching...
No Matches
print.h
1#pragma once
2
3// This file contains implementation of helper methods and classes to perform print operations on a tinyxml2::XMLPrinter.
4
5#include <cgv/media/color.h>
6#include <cgv/math/fvec.h>
7#include <cgv/utils/scan.h>
8
9#include "../tinyxml2/tinyxml2.h"
10
11namespace cgv {
12namespace xml {
13
14void PushAttribute(tinyxml2::XMLPrinter& printer, const std::string& name, const std::string& value) {
15
16 printer.PushAttribute(name.c_str(), value.c_str());
17};
18
19void PushAttribute(tinyxml2::XMLPrinter& printer, const std::string& name, bool value) {
20
21 std::string str = value ? "true" : "false";
22 PushAttribute(printer, name, str);
23};
24
25template<typename T, cgv::type::uint32_type N>
26void PushAttribute(tinyxml2::XMLPrinter& printer, const std::string& name, const cgv::math::fvec<T, N>& value) {
27
28 PushAttribute(printer, name, cgv::math::to_string(value));
29};
30
31void PushAttribute(tinyxml2::XMLPrinter& printer, const std::string& name, const cgv::media::color<float, cgv::media::RGB>& value) {
32
33 cgv::math::fvec<float, 3u> vec(value.R(), value.G(), value.B());
34 PushAttribute(printer, name, cgv::math::to_string(vec));
35};
36
37}
38}
A vector with zero based index.
Definition fvec.h:26
represent a color with components of given type and color and alpha model as specified.
Definition color.h:574
the cgv namespace
Definition print.h:11
Helper functions to process strings.
T B() const
convert color to RGB and return B component
Definition color.h:417
T R() const
convert color to RGB and return R component
Definition color.h:413
T G() const
convert color to RGB and return G component
Definition color.h:415