diff options
author | Stijn Buys <ingar@osirion.org> | 2013-01-27 09:39:13 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2013-01-27 09:39:13 +0000 |
commit | 52a0d3571f56187d8801793b36a5511966e1d9a0 (patch) | |
tree | 95a7fbeedc9bbd5e15d9dc23edf385bebf01b324 /src/filesystem/inistream.cc | |
parent | be1c0d9dd0fe27079f7edd89c55f5eeeff0ae00c (diff) |
Added IniStream methods to read Vector2f keys.
Diffstat (limited to 'src/filesystem/inistream.cc')
-rw-r--r-- | src/filesystem/inistream.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/filesystem/inistream.cc b/src/filesystem/inistream.cc index 15c8ee0..0235440 100644 --- a/src/filesystem/inistream.cc +++ b/src/filesystem/inistream.cc @@ -138,6 +138,44 @@ bool IniStream::got_key_label(const char * keylabel, std::string & labelstring) } } +bool IniStream::got_key_vector2f(const char * keylabel, math::Vector2f & v) +{ + if (last_read_was_key && (key_current.compare(keylabel) == 0)) { + std::istringstream is(value_current); + float x, y; + if ((is >> x) && (is >> y)) { + v.assign(x, y); + } else { + v.clear(); + } + return true; + } else { + return false; + } +} + + +bool IniStream::got_key_vector2f_opt(const char * keylabel, math::Vector2f & v) +{ + if (last_read_was_key && (key_current.compare(keylabel) == 0)) { + std::istringstream is(value_current); + float x, y; + if (is >> x) { + if (!(is >> y)) { + v.assign(x, x); + } else { + v.assign(x, y); + } + } else { + v.clear(); + } + + return true; + } else { + return false; + } +} + bool IniStream::got_key_vector3f(const char * keylabel, math::Vector3f & v) { if (last_read_was_key && (key_current.compare(keylabel) == 0)) { |