TkN 2.4
Toolkit for Nuclei
Loading...
Searching...
No Matches
tkproperty.cpp
1/********************************************************************************
2 * Copyright (c) : Université de Lyon 1, CNRS/IN2P3, UMR5822, *
3 * IP2I, F-69622 Villeurbanne Cedex, France *
4 * Normandie Université, ENSICAEN, UNICAEN, CNRS/IN2P3, *
5 * LPC Caen, F-14000 Caen, France *
6 * Contibutor(s) : *
7 * Jérémie Dudouet jeremie.dudouet@cnrs.fr [2020] *
8 * Diego Gruyer diego.gruyer@cnrs.fr [2020] *
9 * *
10 * Licensed under the MIT License <http://opensource.org/licenses/MIT>. *
11 * SPDX-License-Identifier: MIT *
12 ********************************************************************************/
13
14#include "tkproperty.h"
15
16namespace tkn {
40}
41
42using namespace tkn;
43
45{
46 int nb, nb_unkown, nb_theo_left, nb_theo_right, nb_tenta_left, nb_tenta_right, nb_about;
47 nb = 0;
48
49 // reads the string and counts the specfics characters
50 nb_unkown = _st.count_string("?"); nb += nb_unkown;
51 nb_tenta_left = _st.count_string("("); nb += nb_tenta_left;
52 nb_tenta_right = _st.count_string(")"); nb += nb_tenta_right;
53 nb_theo_left = _st.count_string("["); nb += nb_theo_left;
54 nb_theo_right = _st.count_string("]"); nb += nb_theo_right;
55 nb_about = _st.count_string("~"); nb += nb_about;
56
57 // set the informations
58 if ( nb > 2 ) return kUnknown;
59 if ( nb == 0 ) return kKnown;
60
61 if ( nb == 1 ) {
62 if ( nb_about == 1 ) return kAbout;
63 return kUnknown;
64 }
65 if ( nb_tenta_left == 1 && nb_tenta_right == 1 ) return kTentative;
66 if ( nb_theo_left == 1 && nb_theo_right == 1 ) return kTheo;
67 return kUnknown;
68}
69
70tkstring tkproperty::get_info_str(bool _showknown) const
71{
72 tkstring val;
73 if(fInfo == kKnown && _showknown) val = "known";
74 else if(fInfo == kUnknown) val = "unknown";
75 else if(fInfo == kTentative) val = "tentative";
76 else if(fInfo == kTheo) val = "calculated";
77 else if(fInfo == kAbout) val = "approximated value";
78 else if(fInfo == kSystematic) val = "from systematics";
79 else if(fInfo == kLimit) val = "limit value";
80 else if(fInfo == kUncertain) val = "no uncertainty";
81 else if(fInfo != kKnown) val = "undefined";
82
83 if(fconverted_value) {
84 if(val.is_empty()) val.append("converted");
85 else val.append(", converted");
86 }
87
88 return val;
89}
90
91#ifdef HAS_ROOT
92ClassImp(tkproperty);
93#endif
Any property (data) with flags.
Definition tkproperty.h:28
tkstring get_info_str(bool _showknown=true) const
to print in string the data_info
static data_info what_is(const tkstring &_st)
It deduces from a string the kind of data.
data_info
flags that qualify a given data
Definition tkproperty.h:32
std::string with usefull tricks from TString (ROOT) and KVString (KaliVeda) and more....
Definition tkstring.h:31
bool is_empty() const
Definition tkstring.h:140
int count_string(const tkstring &_st) const
Definition tkstring.cpp:524
tkstring & append(const tkstring &_st)
Definition tkstring.h:204
Definition tklog.cpp:16