Encapsulate the JSON code in a namespace to avoid issues with JSON classes used in opm-parser

This commit is contained in:
Magne Sjaastad committed 2016-06-06 10:43:36 +02:00
1 parent 4fd8e2503c
commit 7742fbe325
5 files changed
+12 -4

No files matched your search

-1
View File
@@ -290,7 +290,6 @@ if(RESINSIGHT_ENABLE_COTIRE)
set_source_files_properties (${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc PROPERTIES COTIRE_EXCLUDED TRUE) set_source_files_properties (${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc PROPERTIES COTIRE_EXCLUDED TRUE)
# TODO: Revisit why opm-parser is not working # TODO: Revisit why opm-parser is not working
# Must namespace JsonReader in RifJsonEncodeDecode to guard agains crash with JSON in opm-parser
set_source_files_properties (${ResInsight_SOURCE_DIR}/ApplicationCode/UnitTests/opm-parser-Test.cpp PROPERTIES COTIRE_EXCLUDED TRUE) set_source_files_properties (${ResInsight_SOURCE_DIR}/ApplicationCode/UnitTests/opm-parser-Test.cpp PROPERTIES COTIRE_EXCLUDED TRUE)
set_target_properties(ResInsight PROPERTIES set_target_properties(ResInsight PROPERTIES
@@ -26,6 +26,7 @@
#include <QtScript/QScriptEngine> #include <QtScript/QScriptEngine>
#include <QtScript/QScriptValueIterator> #include <QtScript/QScriptValueIterator>
namespace ResInsightInternalJson {
QMap<QString, QVariant> JsonReader::decodeFile(QString filePath) QMap<QString, QVariant> JsonReader::decodeFile(QString filePath)
{ {
@@ -141,3 +142,5 @@ QList<QVariant> Json::decodeInnerToList(QScriptValue arrayValue)
} }
return list; return list;
} }
} // end ResInsightInternalJson
@@ -36,6 +36,9 @@
class QScriptEngine; class QScriptEngine;
// Encapsulate the JSON code in a namespace to avoid issues with JSON classes used in opm-parser
namespace ResInsightInternalJson {
class JsonReader class JsonReader
{ {
public: public:
@@ -58,3 +61,6 @@ private:
QMap<QString, QVariant> decodeInner(QScriptValue object); QMap<QString, QVariant> decodeInner(QScriptValue object);
QList<QVariant> decodeInnerToList(QScriptValue arrayValue); QList<QVariant> decodeInnerToList(QScriptValue arrayValue);
}; };
} // end ResInsightInternalJson
@@ -210,7 +210,7 @@ bool RimWellPath::readWellPathFile(QString* errorMessage, RifWellPathAsciiFileRe
void RimWellPath::readJsonWellPathFile() void RimWellPath::readJsonWellPathFile()
{ {
RigWellPath* wellPathGeom = new RigWellPath(); RigWellPath* wellPathGeom = new RigWellPath();
JsonReader jsonReader; ResInsightInternalJson::JsonReader jsonReader;
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(filepath); QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(filepath);
// General well info // General well info
@@ -354,7 +354,7 @@ void RiuWellImportWizard::updateFieldsModel()
if (QFile::exists(fileName)) if (QFile::exists(fileName))
{ {
JsonReader jsonReader; ResInsightInternalJson::JsonReader jsonReader;
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(fileName); QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(fileName);
QStringList regions; QStringList regions;
@@ -581,7 +581,7 @@ void RiuWellImportWizard::parseWellsResponse(RimOilFieldEntry* oilFieldEntry)
if (QFile::exists(oilFieldEntry->wellsFilePath)) if (QFile::exists(oilFieldEntry->wellsFilePath))
{ {
JsonReader jsonReader; ResInsightInternalJson::JsonReader jsonReader;
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(oilFieldEntry->wellsFilePath); QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(oilFieldEntry->wellsFilePath);
QMapIterator<QString, QVariant> it(jsonMap); QMapIterator<QString, QVariant> it(jsonMap);