"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/metgm/MetGmVersion.h" between
fimex-1.4.1.tar.gz and fimex-1.4.2.tar.gz

About: Fimex is a the File Interpolation, Manipulation and EXtraction library for gridded geospatial data. It converts between different, extensible dataformats (currently netcdf, NcML, grib1/2 and felt).

MetGmVersion.h  (fimex-1.4.1):MetGmVersion.h  (fimex-1.4.2)
/* /*
* Fimex * Fimex
* *
* (C) Copyright 2011, met.no * (C) Copyright 2011-2019, met.no
* *
* Project Info: https://wiki.met.no/fimex/start * Project Info: https://wiki.met.no/fimex/start
* *
* This library is free software; you can redistribute it and/or modify it * This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by * under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, but * This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
skipping to change at line 35 skipping to change at line 35
* Used as private/implementation class * Used as private/implementation class
*/ */
#ifndef METGM_VERSION_H #ifndef METGM_VERSION_H
#define METGM_VERSION_H #define METGM_VERSION_H
// METGM C library // METGM C library
// //
#include "metgm.h" #include "metgm.h"
// Fimex
//
#include "fimex/XMLDoc.h"
// libxml2
#include <libxml/tree.h>
#include <libxml/xpath.h>
// standard // standard
// //
#include <memory> #include <memory>
#include <string> #include <string>
namespace MetNoFimex { namespace MetNoFimex {
class XMLDoc;
class MetGmVersion
{
public:
static std::shared_ptr<MetGmVersion> createMetGmVersion(mgm_version version)
;
static std::shared_ptr<MetGmVersion> createMetGmVersion(const std::unique_pt
r<XMLDoc>& doc);
std::string getAsString() const;
inline bool operator==(const MetGmVersion& rh) const { return version_ == rh
.version_; }
inline bool operator==(const mgm_version rh_version) const { return version_
== rh_version; }
inline operator mgm_version() const { return version_; }
inline mgm_version as_mgm_version() const { return version_; }
private:
mgm_version version_;
#define VERSION "metgm_version" explicit MetGmVersion(mgm_version version)
: version_(version)
{
}
};
class MetGmVersion { } // namespace MetNoFimex
public:
static std::shared_ptr<MetGmVersion> createMetGmVersion(mgm_version vers
ion)
{
std::shared_ptr<MetGmVersion> pVersion = std::shared_ptr<MetGmVersio
n>(new MetGmVersion(version));
return pVersion;
}
static std::shared_ptr<MetGmVersion> createMetGmVersion(const std::uniqu
e_ptr<XMLDoc>& doc)
{
mgm_version version = MGM_Edition1;
if(doc.get()) {
xmlXPathObject_p xpathObj = doc->getXPathObject("/metgm/meta_dat
a/attribute");
xmlNodeSetPtr nodes = xpathObj->nodesetval;
size_t size = (nodes) ? nodes->nodeNr : 0;
for (size_t i = 0; i < size; ++i) {
xmlNodePtr node = nodes->nodeTab[i];
std::string attributeName = getXmlProp(node, "name");
if(attributeName == std::string(VERSION)) {
std::string strVersion = getXmlProp(node, "value");
if(strVersion.find("Edition_2") != std::string::npos) {
version = MGM_Edition2;
}
}
}
}
return std::shared_ptr<MetGmVersion>(new MetGmVersion(version));
}
inline std::string getAsString()
{
if(version_ == MGM_Edition1)
return std::string("STANAG 6022 Edition 1");
else if(version_ == MGM_Edition2)
return std::string("STANAG 6022 Edition 2");
else
return std::string("Unknown STANAG 6022 Edition");
}
inline bool operator == (const MetGmVersion &rh) const
{
return version_ == rh.version_;
}
inline bool operator == (const mgm_version rh_version) const
{
return version_ == rh_version;
}
inline operator mgm_version ()
{
return version_;
}
inline mgm_version as_mgm_version()
{
return version_;
}
private:
mgm_version version_;
explicit MetGmVersion(mgm_version version) : version_(version) { }
};
}
#endif // METGM_VERSION_H #endif // METGM_VERSION_H
 End of changes. 5 change blocks. 
81 lines changed or deleted 32 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)