Merge pull request #779 from joakim-hove/new-keywords

New keywords
This commit is contained in:
Joakim Hove
2019-05-22 11:52:47 +02:00
committed by GitHub
8 changed files with 81 additions and 20 deletions

View File

@@ -32,8 +32,8 @@
namespace Json {
void JsonObject::initialize(const std::string& inline_json) {
root = cJSON_Parse( inline_json.c_str() );
if (!root)
this->root = cJSON_Parse( inline_json.c_str() );
if (!this->root)
throw std::invalid_argument("Parsing json input failed");
owner = true;
}
@@ -54,7 +54,12 @@ namespace Json {
if (stream) {
std::string content_from_file( (std::istreambuf_iterator<char>(stream)),
(std::istreambuf_iterator<char>()));
initialize( content_from_file );
this->root = cJSON_Parse( content_from_file.c_str() );
if (!this->root)
throw std::invalid_argument("Parsing json file: " + jsonFile.string() + " failed ");
this->owner = true;
} else
throw std::invalid_argument("Loading json from file: " + jsonFile.string() + " failed.");
}
@@ -63,20 +68,20 @@ namespace Json {
JsonObject::JsonObject( cJSON * object ) {
root = object;
this->root = object;
owner = false;
}
JsonObject::~JsonObject() {
if (owner && root)
cJSON_Delete(root);
if (owner && this->root)
cJSON_Delete(this->root);
}
bool JsonObject::has_item( const std::string& key) const {
cJSON * object = cJSON_GetObjectItem( root , key.c_str() );
cJSON * object = cJSON_GetObjectItem( this->root , key.c_str() );
if (object)
return true;
else
@@ -85,14 +90,14 @@ namespace Json {
bool JsonObject::is_array( ) const {
if (root->type == cJSON_Array)
if (this->root->type == cJSON_Array)
return true;
else
return false;
}
bool JsonObject::is_number( ) const {
if (root->type == cJSON_Number)
if (this->root->type == cJSON_Number)
return true;
else
return false;
@@ -100,14 +105,14 @@ namespace Json {
bool JsonObject::is_string( ) const {
if (root->type == cJSON_String)
if (this->root->type == cJSON_String)
return true;
else
return false;
}
bool JsonObject::is_object( ) const {
if (root->type == cJSON_Object)
if (this->root->type == cJSON_Object)
return true;
else
return false;
@@ -115,14 +120,14 @@ namespace Json {
size_t JsonObject::size() const {
int int_size = cJSON_GetArraySize( root );
int int_size = cJSON_GetArraySize( this->root );
return (size_t) int_size;
}
JsonObject JsonObject::get_array_item( size_t index ) const {
if (is_array()) {
cJSON * new_c_ptr = cJSON_GetArrayItem( root , index );
cJSON * new_c_ptr = cJSON_GetArrayItem( this->root , index );
if (new_c_ptr)
return JsonObject( new_c_ptr );
else
@@ -133,7 +138,7 @@ namespace Json {
JsonObject JsonObject::get_item(const std::string& key) const {
cJSON * c_ptr = cJSON_GetObjectItem( root , key.c_str() );
cJSON * c_ptr = cJSON_GetObjectItem( this->root , key.c_str() );
if (c_ptr)
return JsonObject( c_ptr );
else
@@ -149,7 +154,7 @@ namespace Json {
std::string JsonObject::as_string() const {
if (is_string())
return root->valuestring;
return this->root->valuestring;
else
throw std::invalid_argument("Object is not a string object");
}
@@ -162,8 +167,8 @@ namespace Json {
int JsonObject::as_int() const {
if (root->type == cJSON_Number)
return root->valueint;
if (this->root->type == cJSON_Number)
return this->root->valueint;
else
throw std::invalid_argument("Object is not a number object.");
}
@@ -176,8 +181,8 @@ namespace Json {
double JsonObject::as_double() const {
if (root->type == cJSON_Number)
return root->valuedouble;
if (this->root->type == cJSON_Number)
return this->root->valuedouble;
else
throw std::invalid_argument("Object is not a number object.");
}
@@ -194,7 +199,7 @@ namespace Json {
std::string JsonObject::to_string() const {
char * c_str = cJSON_Print( root );
char * c_str = cJSON_Print( this->root );
std::string s(c_str);
free( c_str );

View File

@@ -0,0 +1,7 @@
{"name" : "BRANPROP", "sections" : ["SCHEDULE"], "items" : [
{"name" : "DOWNTREE_NODE", "value_type" : "STRING"},
{"name" : "UPTREE_NODE", "value_type" : "STRING"},
{"name" : "VFP_TABLE", "value_type" : "INT"},
{"name" : "ALQ", "value_type" : "DOUBLE", "default" : 0},
{"name" : "ALQ_SURFACE_DENSITY", "value_type" : "STRING", "default" : "NONE"}
]}

View File

@@ -0,0 +1,7 @@
{"name" : "GCONSALE" , "sections" : ["SCHEDULE"], "items" : [
{"name" : "GROUP" , "value_type" : "STRING" },
{"name" : "SALES_TARGET" , "value_type" : "UDA", "dimension": "GasSurfaceVolume/Time"},
{"name" : "MAX_SALES_RATE" , "value_type" : "UDA", "dimension": "GasSurfaceVolume/Time"},
{"name" : "MIN_SALES_RATE" , "value_type" : "UDA", "dimension": "GasSurfaceVolume/Time", "default" : -1e20},
{"name" : "MAX_PROC" , "value_type" : "STRING", "default" : "NONE"}
]}

View File

@@ -0,0 +1,6 @@
{"name" : "GCONSUMP" , "sections" : ["SCHEDULE"], "items" : [
{"name" : "GROUP" , "value_type" : "STRING" },
{"name" : "GAS_CONSUMP_RATE" , "value_type" : "UDA", "dimension": "GasSurfaceVolume/Time"},
{"name" : "GAS_IMPORT_RATE" , "value_type" : "UDA", "dimension": "GasSurfaceVolume/Time"},
{"name" : "NETWORK_NODE" , "value_type" : "STRING"}
]}

View File

@@ -0,0 +1,9 @@
{"name" : "GPMAINT" , "sections" : ["SCHEDULE"], "items" : [
{"name" : "GROUP" , "value_type" : "STRING" },
{"name" : "FLOW_TARGET" , "value_type" : "STRING"},
{"name" : "REGION" , "value_type" : "INT"},
{"name" : "FIP_FAMILY" , "value_type" : "STRING"},
{"name" : "PRESSURE_TARGET" , "value_type" : "DOUBLE" , "dimension" : "Pressure"},
{"name" : "PROP_CONSTANT" , "value_type" : "DOUBLE" , "dimension" : "ReservoirVolume/Time*Pressure"},
{"name" : "TIME_CONSTANT" , "value_type" : "DOUBLE" , "dimension" : "Time"}
]}

View File

@@ -0,0 +1,14 @@
{"name" : "GUIDERAT", "sections" : ["SCHEDULE"], "size": 1,
"items" : [
{"name" : "MIN_CALC_TIME", "value_type" : "DOUBLE", "dimension" : "Time", "default" : 0},
{"name" : "NOMINATED_PHASE", "value_type" : "STRING", "default" : "NONE"},
{"name" : "A", "value_type" :"DOUBLE", "default" : 0},
{"name" : "B", "value_type" :"DOUBLE", "default" : 0},
{"name" : "C", "value_type" :"DOUBLE", "default" : 0},
{"name" : "D", "value_type" :"DOUBLE", "default" : 0},
{"name" : "E", "value_type" :"DOUBLE", "default" : 0},
{"name" : "F", "value_type" :"DOUBLE", "default" : 0},
{"name" : "ALLOW_INCREASE", "value_type" : "STRING", "default": "YES"},
{"name" : "DAMPING_FACTOR", "value_type" : "DOUBLE", "default": 1.0},
{"name" : "USE_FREE_GAS", "value_type" : "STRING", "default": "NO"},
{"name" : "MIN_GUIDE_RATE", "value_type" : "DOUBLE", "default" : 1e-6}]}

View File

@@ -0,0 +1,7 @@
{"name" : "NODEPROP", "sections" : ["SCHEDULE"], "items" : [
{"name" : "NAME", "value_type" : "STRING"},
{"name" : "PRESSURE", "value_type" : "DOUBLE", "dimension" : "Pressure"},
{"name" : "AS_CHOKE", "value_type" : "STRING", "default" : "NO"},
{"name" : "CHOKE_GROUP", "value_type" : "STRING"},
{"name" : "SOURCE_SINK_GROUP", "value_type" : "STRING"},
{"name" : "NETWORK_VALUE_TYPE", "value_type" : "STRING", "default" : "PROD"}]}

View File

@@ -34,6 +34,7 @@ set( keywords
000_Eclipse100/B/BLACKOIL
000_Eclipse100/B/BLOCK_PROBE
000_Eclipse100/B/BOX
000_Eclipse100/B/BRANPROP
000_Eclipse100/C/CARFIN
000_Eclipse100/C/CECON
000_Eclipse100/C/COMPDAT
@@ -112,6 +113,8 @@ set( keywords
000_Eclipse100/G/GAS
000_Eclipse100/G/GCONINJE
000_Eclipse100/G/GCONPROD
000_Eclipse100/G/GCONSALE
000_Eclipse100/G/GCONSUMP
000_Eclipse100/G/GDFILE
000_Eclipse100/G/GDORIENT
000_Eclipse100/G/GECON
@@ -119,6 +122,7 @@ set( keywords
000_Eclipse100/G/GLIFTOPT
000_Eclipse100/G/GMWSET
000_Eclipse100/G/GNETINJE
000_Eclipse100/G/GPMAINT
000_Eclipse100/G/GRAVITY
000_Eclipse100/G/GRID
000_Eclipse100/G/GRIDFILE
@@ -128,6 +132,7 @@ set( keywords
000_Eclipse100/G/GRUPNET
000_Eclipse100/G/GRUPTREE
000_Eclipse100/G/GSATPROD
000_Eclipse100/G/GUIDERAT
000_Eclipse100/I/IMBNUM
000_Eclipse100/I/IMKRVD
000_Eclipse100/I/IMPES
@@ -182,6 +187,7 @@ set( keywords
000_Eclipse100/N/NEXTSTEP
000_Eclipse100/N/NNC
000_Eclipse100/N/NOCASC
000_Eclipse100/N/NODEPROP
000_Eclipse100/N/NOECHO
000_Eclipse100/N/NOGGF
000_Eclipse100/N/NOINSPEC