Skip to content
Snippets Groups Projects
Commit 838756a6 authored by Tom Fischer's avatar Tom Fischer Committed by Lars Bilke
Browse files

[GO2OGS] Impl. of Region.

parent d8ee8fcd
No related branches found
No related tags found
No related merge requests found
/**
*
* @copyright
* Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/LICENSE.txt
*/
#include <iterator>
#include <sstream>
#include <logog/include/logog.hpp>
#include "Region.h"
namespace FileIO
{
namespace Gocad
{
std::ostream& operator<<(std::ostream& os, Region const& r)
{
return os << "(" << r.name << "|" << r.bit << ")";
}
Region parseRegion(std::string const& line)
{
std::istringstream iss(line);
std::istream_iterator<std::string> it(iss);
// Check first word is REGION or MODEL_REGION.
if (*it != std::string("REGION") && *it != std::string("MODEL_REGION"))
{
ERR("Expected REGION or MODEL_REGION keyword but '%s' found.\n",
it->c_str());
throw std::runtime_error(
"In parseRegion() expected REGION or MODEL_REGION keyword not "
"found.\n");
}
++it;
Region r;
r.name = *it;
++it;
r.bit = atoi(it->c_str());
return r;
}
} // end namespace Gocad
} // end namespace FileIO
/**
*
* @copyright
* Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/LICENSE.txt
*/
#pragma once
#include <string>
#include <vector>
namespace FileIO
{
namespace Gocad
{
struct Region final
{
std::string name;
unsigned bit{};
bool operator==(Region const& r) const { return bit == r.bit; }
};
std::ostream& operator<<(std::ostream& os, Region const& r);
Region parseRegion(std::string const& line);
} // end namespace Gocad
} // end namespace FileIO
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment