[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] (no subject)
From: |
Konstantinos Poulios |
Subject: |
[Getfem-commits] (no subject) |
Date: |
Tue, 1 Aug 2017 16:54:47 -0400 (EDT) |
branch: devel-logari81
commit cc2a093e9db5999373c204b97155ce3fb587e26e
Author: Konstantinos Poulios <address@hidden>
Date: Tue Aug 1 22:54:39 2017 +0200
add support for default values in md_param
---
src/bgeot_ftool.cc | 19 ++++++++++++-------
src/getfem/bgeot_ftool.h | 9 ++++++---
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/src/bgeot_ftool.cc b/src/bgeot_ftool.cc
index 85b3c25..14b1729 100644
--- a/src/bgeot_ftool.cc
+++ b/src/bgeot_ftool.cc
@@ -435,9 +435,11 @@ namespace bgeot {
}
}
- double md_param::real_value(const std::string &name, const char *comment) {
+ double md_param::real_value(const std::string &name, const char *comment,
+ double default_val) {
if (parameters.find(name) == parameters.end()) {
- if (comment == 0) return 0.0;
+ if (comment == 0)
+ return default_val;
else {
double f;
gmm::standard_locale sl;
@@ -452,9 +454,11 @@ namespace bgeot {
return p.real();
}
- long md_param::int_value(const std::string &name, const char *comment) {
+ long md_param::int_value(const std::string &name, const char *comment,
+ long default_val) {
if (parameters.find(name) == parameters.end()) {
- if (comment == 0) return 0;
+ if (comment == 0)
+ return default_val;
else {
long f;
gmm::standard_locale sl;
@@ -470,10 +474,11 @@ namespace bgeot {
}
const std::string &md_param::string_value(const std::string &name,
- const char *comment) {
- static const std::string empty_string;
+ const char *comment,
+ const std::string &default_val) {
if (parameters.find(name) == parameters.end()) {
- if (comment == 0) return empty_string;
+ if (comment == 0)
+ return default_val;
else {
std::string s;
gmm::standard_locale sl;
diff --git a/src/getfem/bgeot_ftool.h b/src/getfem/bgeot_ftool.h
index 4390914..8dac8a7 100644
--- a/src/getfem/bgeot_ftool.h
+++ b/src/getfem/bgeot_ftool.h
@@ -174,10 +174,13 @@ namespace bgeot
public :
- double real_value(const std::string &name, const char *comment = 0);
- long int_value(const std::string &name, const char *comment = 0);
+ double real_value(const std::string &name, const char *comment = 0,
+ double default_val=0.);
+ long int_value(const std::string &name, const char *comment = 0,
+ long default_val=0);
const std::string &string_value(const std::string &name,
- const char *comment = 0);
+ const char *comment = 0,
+ const std::string &default_val="");
const std::vector<param_value> &array_value(const std::string &name,
const char *comment = 0);
void add_int_param(const std::string &name, long e)