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