OGS
Region.cpp
Go to the documentation of this file.
1
10#include "Region.h"
11
12#include <iterator>
13#include <sstream>
14
15#include "BaseLib/Logging.h"
16
17namespace FileIO
18{
19namespace Gocad
20{
21std::ostream& operator<<(std::ostream& os, Region const& r)
22{
23 return os << "(" << r.name << "|" << r.bit << ")";
24}
25
26Region parseRegion(std::string const& line)
27{
28 std::istringstream iss(line);
29 std::istream_iterator<std::string> it(iss);
30 // Check first word is REGION or MODEL_REGION.
31 if (*it != std::string("REGION") && *it != std::string("MODEL_REGION"))
32 {
33 ERR("Expected REGION or MODEL_REGION keyword but '{:s}' found.\n",
34 it->c_str());
35 throw std::runtime_error(
36 "In parseRegion() expected REGION or MODEL_REGION keyword not "
37 "found.\n");
38 }
39 ++it;
40
41 Region r;
42 r.name = *it;
43 ++it;
44 r.bit = atoi(it->c_str());
45
46 return r;
47}
48
49} // end namespace Gocad
50} // end namespace FileIO
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:45
std::ostream & operator<<(std::ostream &os, CoordinateSystem const &c)
Region parseRegion(std::string const &line)
Definition Region.cpp:26
std::string name
Definition Region.h:21