-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoopVersion.cpp
66 lines (61 loc) · 2.18 KB
/
LoopVersion.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "LoopVersion.h"
namespace LoopProjectFile {
LoopProjectFileResponse LoopVersion::SetVersion(netCDF::NcGroup* rootNode, bool verbose)
{
LoopProjectFileResponse resp = {0,""};
if (!rootNode) {
resp = createErrorMsg(1,"ERROR: Root Node invalid!");
return resp;
}
try {
rootNode->putAtt("loopMajorVersion",netCDF::ncInt64,LoopVersionMajor);
rootNode->putAtt("loopMinorVersion",netCDF::ncInt64,LoopVersionMinor);
rootNode->putAtt("loopSubVersion",netCDF::ncInt64,LoopVersionSub);
} catch (netCDF::exceptions::NcException& e) {
if (verbose) e.what();
resp = createErrorMsg(1,"ERROR: Failure to set version on netCDF file", verbose);
}
return resp;
}
bool LoopVersion::CheckVersionValid(netCDF::NcGroup* rootNode, bool verbose)
{
LoopVersion version;
if (!rootNode->isNull()) {
return false;
}
try {
rootNode->getAtt("loopMajorVersion").getValues(&version.majorVersion);
rootNode->getAtt("loopMinorVersion").getValues(&version.minorVersion);
rootNode->getAtt("loopSubVersion").getValues(&version.subVersion);
if (verbose) {
std::cout << " Loop Project File version = "
<< version.majorVersion << "." << version.minorVersion << "." << version.subVersion
<< std::endl;
}
} catch (netCDF::exceptions::NcException& e) {
if (verbose) std::cout << e.what();
return false;
}
return true;
}
LoopVersion LoopVersion::GetVersion(netCDF::NcGroup* rootNode, bool verbose)
{
LoopVersion version;
if (rootNode->isNull()) {
return version;
}
try {
rootNode->getAtt("loopMajorVersion").getValues(&version.majorVersion);
rootNode->getAtt("loopMinorVersion").getValues(&version.minorVersion);
rootNode->getAtt("loopSubVersion").getValues(&version.subVersion);
version.errored = false;
} catch (netCDF::exceptions::NcException& e) {
if (verbose) {
e.what();
std::cout << "No valid Version in Loop Project File" << std::endl;
version.errored = true;
}
}
return version;
}
} // namespace LoopProjectFile