Commit ce7458c4 authored by kraus's avatar kraus
Browse files

take opal version number from configuration

parent 43937be1
......@@ -21,6 +21,7 @@
#include "Attributes/Attributes.h"
#include "Utilities/Options.h"
#include "Physics/Physics.h"
#include "config.h"
#include <cmath>
#include <iostream>
......@@ -54,7 +55,20 @@ RealConstant::RealConstant():
OPAL->create(new RealConstant("CLIGHT", this, Physics::c));
OPAL->create(new RealConstant("OPALVERSION", this, 120));
std::string version_str(PACKAGE_VERSION);
int version = 0;
{
size_t i = 0;
while (i < version_str.size()) {
size_t n = version_str.find_first_of("0123456789",i);
if (n != std::string::npos) {
version = version * 10 + version_str[n] - 48;
version_str[n] = '.';
}
i = n;
}
}
OPAL->create(new RealConstant("OPALVERSION", this, version));
}
......@@ -94,4 +108,4 @@ double RealConstant::getReal() const {
void RealConstant::print(std::ostream &os) const {
os << "REAL CONST " << getOpalName() << '=' << itsAttr[0] << ';';
os << std::endl;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment