void ToVal()

in src/common/utils/RapidCsv.h [142:209]


  void ToVal(const std::string &pStr, T &pVal) const {
    try {
      if (typeid(T) == typeid(int)) {
        pVal = static_cast<T>(std::stoi(pStr));
        return;
      } else if (typeid(T) == typeid(long)) {
        pVal = static_cast<T>(std::stol(pStr));
        return;
      } else if (typeid(T) == typeid(long long)) {
        pVal = static_cast<T>(std::stoll(pStr));
        return;
      } else if (typeid(T) == typeid(unsigned)) {
        pVal = static_cast<T>(std::stoul(pStr));
        return;
      } else if (typeid(T) == typeid(unsigned long)) {
        pVal = static_cast<T>(std::stoul(pStr));
        return;
      } else if (typeid(T) == typeid(unsigned long long)) {
        pVal = static_cast<T>(std::stoull(pStr));
        return;
      }
    } catch (...) {
      if (!mConverterParams.mHasDefaultConverter) {
        throw;
      } else {
        pVal = static_cast<T>(mConverterParams.mDefaultInteger);
        return;
      }
    }

    try {
      if (mConverterParams.mNumericLocale) {
        if (typeid(T) == typeid(float)) {
          pVal = static_cast<T>(std::stof(pStr));
          return;
        } else if (typeid(T) == typeid(double)) {
          pVal = static_cast<T>(std::stod(pStr));
          return;
        } else if (typeid(T) == typeid(long double)) {
          pVal = static_cast<T>(std::stold(pStr));
          return;
        }
      } else {
        if ((typeid(T) == typeid(float)) || (typeid(T) == typeid(double)) || (typeid(T) == typeid(long double))) {
          std::istringstream iss(pStr);
          iss >> pVal;
          if (iss.fail() || iss.bad() || !iss.eof()) {
            throw std::invalid_argument("istringstream: no conversion");
          }
          return;
        }
      }
    } catch (...) {
      if (!mConverterParams.mHasDefaultConverter) {
        throw;
      } else {
        pVal = static_cast<T>(mConverterParams.mDefaultFloat);
        return;
      }
    }

    if (typeid(T) == typeid(char)) {
      pVal = static_cast<T>(pStr[0]);
      return;
    } else {
      throw no_converter();
    }
  }