source: OGRE/trunk/ogrenew/Tools/VRMLConverter/vrmllib/src/types.cpp @ 692

Revision 692, 1.1 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

Line 
1#include <vrmllib/types_bits.h>
2
3namespace vrmllib {
4namespace bits {
5
6void parse_value(bool &b, std::istream &s, file &)
7{
8        std::string t;
9        s >> t;
10        if (t == "TRUE")
11                b = true;
12        else if (t == "FALSE")
13                b = false;
14        else
15                throw std::runtime_error("parse error: expected TRUE or FALSE, got: " + t);
16}
17
18void parse_value(std::string &str, std::istream &s, file &)
19{
20        char c = 0;
21        s >> c;
22
23        if (c != '"') {
24                s.putback(c);
25                throw std::runtime_error(std::string("expected start of string (\"), got: ") + c);
26        }
27        str.erase();
28        c = 0;
29        while (s.get(c) && c != '"') str += c;
30
31        if (c != '"') {
32                throw std::runtime_error(std::string("expected end of string (\"), got: ") + c);
33        }
34}
35
36void parse_value(vec3 &v, std::istream &s, file &)
37{
38        s >> v.x >> v.y >> v.z;
39}
40
41void parse_value(col3 &v, std::istream &s, file &)
42{
43        s >> v.r >> v.g >> v.b;
44}
45
46void parse_value(vec2 &v, std::istream &s, file &)
47{
48        s >> v.x >> v.y;
49}
50
51void parse_value(rot &r, std::istream &s, file &f)
52{
53        parse_value(r.vector, s, f);
54        s >> r.radians;
55}
56
57} // namespace bits
58} // namespace vrmllib
Note: See TracBrowser for help on using the repository browser.