8#ifndef FMTparser_H_INCLUDED
9#define FMTparser_H_INCLUDED
11#include <boost/regex.hpp>
23#include <boost/thread/recursive_mutex.hpp>
28#if defined FMTWITHGDAL
29 class OGRSpatialReference;
34 class OGRSpatialReference;
35 class OGRCoordinateTransformation;
70 const static boost::regex rxvectortheme;
73 const static boost::regex rxnumber;
76 const static boost::regex rxremovecomment;
79 const static boost::regex rxvalid;
82 const static boost::regex rxinclude;
85 const static boost::regex rxfor;
88 const static boost::regex rxend;
91 static std::map<Core::FMTsection, std::string>primary_sections;
97 std::queue<std::string>_forvalues;
100 std::queue<std::string>_included;
103 static bool GDALinitialization;
106 std::istream& safeGetline(std::istream& is, std::string& t)
const;
112 static void initializeGDAL();
117 mutable boost::recursive_mutex
mtx;
164 std::vector<GDALDriver*>
getallGDALdrivers(
const char* spatialtype,
bool testcreation=
true)
const;
169 std::vector<std::vector<std::string>>
getGDALextensions(
const char* spatialtype,
bool testcreation =
true)
const;
174 void setcategories(GDALRasterBand* band,
const std::vector<std::string>& categories)
const;
180 OGRCoordinateTransformation*
getprojtransform(OGRLayer* baselayer,
bool fittoforel =
true)
const;
186 GDALDataset*
gettransformmemlayercopy(OGRLayer* baselayer,
const OGRSpatialReference* newreference,
const std::string& fieldname)
const;
212 OGRLayer*
getlayer(GDALDataset* dataset,
int id)
const;
217 GDALRasterBand*
getband(GDALDataset* dataset,
int bandid=1)
const;
222 GDALRasterBand*
createband(GDALDataset* dataset,
const std::vector<std::string>& categories,
int bandid=1)
const;
227 std::vector<std::string>
getcat(GDALDataset* dataset,
int bandid=1)
const;
232 GDALRasterBand*
getoverview(GDALRasterBand* band,
int view=1)
const;
237 void getWSfields(OGRLayer* layer, std::map<int,int>& themes,
int& age,
int& area,
int& lock, std::string agefield=
"", std::string areafield=
"", std::string lockfield=
"")
const;
253 std::vector<std::string>
sameas(
const std::string& allset)
const;
258 std::map<Core::FMTsection, std::string>
getprimary(
const std::string& primarylocation);
288 std::vector<std::vector<std::string>>
readcsv(
const std::string& location,
const char& separator);
328 bool tryopening(
const std::ifstream& stream,
const std::string& location)
const;
333 bool tryopening(std::ofstream& stream,
const std::string& location)
const;
348 std::vector<std::string>
regexloop(
const boost::regex& cutregex, std::string& str)
const;
353 std::vector<std::string>
spliter(std::string strmask,
const boost::regex& xspliter)
const;
363 std::string
upper(
const std::string& lowercases)
const;
383 bool getforloops(std::string& line,
const std::vector<Core::FMTtheme>& themes,
const Core::FMTconstants& cons, std::vector<std::string>& allvalues, std::string& target);
393 bool isnum(std::string value)
const;
410 T
getnum(
const std::string& value,
bool omitnumtest=
false)
const;
428 GDALDataset*
createOGRdataset(std::string location = std::string(),std::string gdaldrivername =
"CSV")
const;
434 const std::string& name, std::vector<std::string> creationoptions = std::vector<std::string>())
const;
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTbounds.hpp:27
Definition: FMTconstants.hpp:29
Definition: FMTobject.hpp:50
Definition: FMTbounds.hpp:342
Definition: FMTyields.hpp:40
Definition: FMTparser.hpp:66
std::queue< std::string > tryinclude(const std::string &line, const std::vector< Core::FMTtheme > &themes, const Core::FMTconstants &cons)
Core::FMTsection _section
The section in which the child class is in.
Definition: FMTparser.hpp:120
std::string upper(const std::string &lowercases) const
static const boost::regex rxseparator
A regex for splitting general string.
Definition: FMTparser.hpp:292
std::string _comment
Comment found in the actual line read by the parser.
Definition: FMTparser.hpp:147
GDALRasterBand * createband(GDALDataset *dataset, const std::vector< std::string > &categories, int bandid=1) const
std::vector< std::string > spliter(std::string strmask, const boost::regex &xspliter) const
Core::FMTbounds< T > bounds(const Core::FMTconstants &constants, const std::string &value, const std::string &ope, Core::FMTsection section) const
bool isvalidfile(const std::string &location) const
std::vector< std::vector< std::string > > getGDALrasterdriverextensions(bool testcreation=true) const
GDALDataset * createOGRdataset(std::string location=std::string(), std::string gdaldrivername="CSV") const
static const boost::regex rxaage
A regex for capturing age specificaiton.
Definition: FMTparser.hpp:126
std::string getcleanlinewfor(std::ifstream &stream, const std::vector< Core::FMTtheme > &themes, const Core::FMTconstants &cons)
std::time_t getmostrecentfiletime() const
GDALRasterBand * getoverview(GDALRasterBand *band, int view=1) const
bool isnum(const std::string &value, const Core::FMTconstants &constant, bool throwerror=true) const
bool isnum(std::string value) const
std::vector< std::string > getGDALvectordrivernames(bool testcreation=true) const
GDALDataset * createvectormemoryds() const
std::vector< std::vector< std::string > > readcsv(const std::string &location, const char &separator)
bool tryfillnumber(T &number, const std::string &value, const Core::FMTconstants &constant, int period=0) const
std::string returninclude(const std::string &line, const std::vector< Core::FMTtheme > &themes, const Core::FMTconstants &cons)
virtual ~FMTparser()=default
static const boost::regex rxayldage
A regex for capturing age or yield specification.
Definition: FMTparser.hpp:129
std::string setspec(Core::FMTsection section, Core::FMTkwor key, const Core::FMTyields &ylds, const Core::FMTconstants &constants, Core::FMTspec &spec, const std::string &line)
GDALDataset * createdataset(const std::string &location, const Spatial::FMTlayer< T > &layer, const int datatypeid, std::string format="GTiff") const
int _line
Line id at which the parser is reading the values.
Definition: FMTparser.hpp:144
bool isact(Core::FMTsection section, const std::vector< Core::FMTaction > &actions, std::string action) const
std::vector< std::string > getGDALrasterdrivernames(bool testcreation=true) const
int _constreplacement
Number of constant replaced by a numerical number.
Definition: FMTparser.hpp:141
std::vector< std::string > regexloop(const boost::regex &cutregex, std::string &str) const
OGRCoordinateTransformation * getprojtransform(OGRLayer *baselayer, bool fittoforel=true) const
OGRLayer * createlayer(GDALDataset *dataset, const std::string &name, std::vector< std::string > creationoptions=std::vector< std::string >()) const
OGRLayer * getlayer(GDALDataset *dataset, int id) const
void setcategories(GDALRasterBand *band, const std::vector< std::string > &categories) const
std::time_t mostrecentfile
The most recent file time read by this parser.
Definition: FMTparser.hpp:153
static const boost::regex rxoperators
A regex for capturing simple operators.
Definition: FMTparser.hpp:135
void getWSfields(OGRLayer *layer, std::map< int, int > &themes, int &age, int &area, int &lock, std::string agefield="", std::string areafield="", std::string lockfield="") const
static const boost::regex rxprimary
A regex for capturing the primary file.
Definition: FMTparser.hpp:138
T getnum(const std::string &value, bool omitnumtest=false) const
std::string setspecs(Core::FMTsection section, Core::FMTkwor key, const Core::FMTyields &ylds, const Core::FMTconstants &constants, std::vector< Core::FMTspec > &specs, const std::string &line)
void clearcomments(std::string &line)
FMTparser(const FMTparser &rhs)
boost::recursive_mutex mtx
Mutex for multi-threading.
Definition: FMTparser.hpp:117
void setsection(const Core::FMTsection §ion) const
bool tryopening(std::ofstream &stream, const std::string &location) const
std::vector< std::vector< std::string > > getGDALvectordriverextensions(bool testcreation=true) const
T getnum(const std::string &value, const Core::FMTconstants &constant, int period=0) const
std::map< Core::FMTsection, std::string > getprimary(const std::string &primarylocation)
std::array< std::string, 5 > getbaseoperators() const
std::string getcleanline(std::ifstream &stream)
std::vector< std::string > sameas(const std::string &allset) const
Core::FMTsection from_extension(const std::string &ext) const
static const boost::regex rxayld
A regex for capturing age/period/yield specification.
Definition: FMTparser.hpp:123
GDALDataset * getvectordataset(const std::string &location) const
std::vector< std::vector< std::string > > getGDALextensions(const char *spatialtype, bool testcreation=true) const
std::unique_ptr< OGRSpatialReference > getFORELspatialref() const
static const boost::regex rxbounds
A regex for capturing bounds for yield or age specification.
Definition: FMTparser.hpp:132
GDALDataset * getdataset(const std::string &location) const
GDALDataset * gettransformmemlayercopy(OGRLayer *baselayer, const OGRSpatialReference *newreference, const std::string &fieldname) const
bool isyld(const Core::FMTyields &ylds, const std::string &value, Core::FMTsection section) const
bool isvalid(const std::string &line) const
bool getforloops(std::string &line, const std::vector< Core::FMTtheme > &themes, const Core::FMTconstants &cons, std::vector< std::string > &allvalues, std::string &target)
std::vector< std::string > getcat(GDALDataset *dataset, int bandid=1) const
std::string _location
File location of the section read by the parser.
Definition: FMTparser.hpp:150
bool tryopening(const std::ifstream &stream, const std::string &location) const
std::vector< GDALDriver * > getallGDALdrivers(const char *spatialtype, bool testcreation=true) const
void setheader(const std::string &header)
GDALRasterBand * getband(GDALDataset *dataset, int bandid=1) const
Definition: FMTlayer.hpp:29
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
FMTsection
Definition: FMTutility.hpp:23
FMTkwor
Definition: FMTutility.hpp:39
Namespace handling all FMT's parsers. Everything related to I/O should be located in this namespace.
Definition: FMTactionparser.hpp:26
The spatial namespace provides classes for spatialy explicit simulation/optimization based on raster ...
Definition: FMTareaparser.hpp:36