title: How to properly load values of a full dataset of variables from a file?
body: <p>Hi stackoverflow community,</p>
  
  <p>I have currently a dataset of constants in my code which is loaded from a text file. Those variables are used all the times in a learning algorithm so I declared them as member of my class for execution speed (example below with 6 but I have 100+ of them) :</p>
  
  <pre class="lang-cpp prettyprint-override"><code>class learningGraphDataset
  {
  public:
     learningGraphDataset();
     loadDatasetValuesFromTextFile();
  
  private:
      // DATASET
      uint32_t _CST_FACTOR_MIN1;
      uint32_t _CST_FACTOR_MIN2; 
      uint32_t _CST_FACTOR_MAX12;
      uint32_t _CST_FACTOR_MAX12;
      **
      ** (many others)
      **
      uint32_t _CST_LIMIT13;
  };
  </code></pre>
  
  <p>I keep all the values in a file to be able to generate a new set of data (genetic algorithm), and restart the soft with the new dataset text file.</p>
  
  <p>The problem is when I want to load each values from the text file, I have something like 800 lines of :</p>
  
  <pre class="lang-cpp prettyprint-override"><code>QString cstName = tmpLineSplitted[0];
  uint32_t cstVal = tmpLineSplitted[1].toUInt();
  if (cstName == "CST_FACTOR_MIN1_VAL") 
  {
       _CST_FACTOR_MIN1 = cstVal;
       errorOnLine=false;
       nbConstantsLoaded++;
  }
  else if (cstName == "CST_FACTOR_MIN2_VAL") 
  {
       _CST_FACTOR_MIN2 = cstVal;
       errorOnLine=false;
       nbConstantsLoaded++;
  }
  **
  **(many others)
  **
  else if (cstName == "CST_LIMIT13_VAL") 
  {
       _CST_LIMIT13 = cstVal;
       errorOnLine=false;
       nbConstantsLoaded++;
  }
  </code></pre>
  
  <p>And to add one more constant it begin to be quite slow.
  My text file look like this :</p>
  
  <pre class="lang-cpp prettyprint-override"><code>CST_FACTOR_MIN1_VAL;61;
  CST_FACTOR_MIN2_VAL;13;
  **
  **(many others)
  **
  CST_LIMIT13_VAL;27;
  </code></pre>
  
  <p>I know that in C++ there is no way to load a variable like this ("reflective" language?)</p>
  
  <pre class="lang-cpp prettyprint-override"><code>variable("_CST_FACTOR_MIN1") = cstVal;
  </code></pre>
  
  <p>The code works but is there a way to write all this in a nicer way? Mapping maybe? With everything on two column maybe (var name in text file &amp; real var name)? If a could load all the constants with a loop that would help to get a more clear code.</p>
  
  <p>I use C++11 &amp; the Qt5 lib</p>
  
  <p>Thanks a lot</p>