diff --git a/include/ocpp/common/cistring.hpp b/include/ocpp/common/cistring.hpp index 56d12544a..be6a08dd1 100644 --- a/include/ocpp/common/cistring.hpp +++ b/include/ocpp/common/cistring.hpp @@ -23,6 +23,9 @@ template class CiString : public String { CiString(const char* data) : String(data) { } + CiString(const CiString& data) : String(data.get()) { + } + /// \brief Creates a string CiString() : String() { } @@ -39,7 +42,7 @@ template class CiString : public String { } /// \brief Conversion operator to turn a String into std::string - operator std::string() { + operator std::string() const { return this->get(); } }; diff --git a/lib/ocpp/v16/charge_point_configuration.cpp b/lib/ocpp/v16/charge_point_configuration.cpp index f6574cb20..711739010 100644 --- a/lib/ocpp/v16/charge_point_configuration.cpp +++ b/lib/ocpp/v16/charge_point_configuration.cpp @@ -219,47 +219,47 @@ std::string ChargePointConfiguration::getChargeBoxSerialNumber() { } CiString<20> ChargePointConfiguration::getChargePointModel() { - return CiString<20>(this->config["Internal"]["ChargePointModel"]); + return CiString<20>(this->config["Internal"]["ChargePointModel"].get()); } std::optional> ChargePointConfiguration::getChargePointSerialNumber() { std::optional> charge_point_serial_number = std::nullopt; if (this->config["Internal"].contains("ChargePointSerialNumber")) { - charge_point_serial_number.emplace(this->config["Internal"]["ChargePointSerialNumber"]); + charge_point_serial_number.emplace(this->config["Internal"]["ChargePointSerialNumber"].get()); } return charge_point_serial_number; } CiString<20> ChargePointConfiguration::getChargePointVendor() { - return CiString<20>(this->config["Internal"]["ChargePointVendor"]); + return CiString<20>(this->config["Internal"]["ChargePointVendor"].get()); } CiString<50> ChargePointConfiguration::getFirmwareVersion() { - return CiString<50>(this->config["Internal"]["FirmwareVersion"]); + return CiString<50>(this->config["Internal"]["FirmwareVersion"].get()); } std::optional> ChargePointConfiguration::getICCID() { std::optional> iccid = std::nullopt; if (this->config["Internal"].contains("ICCID")) { - iccid.emplace(this->config["Internal"]["ICCID"]); + iccid.emplace(this->config["Internal"]["ICCID"].get()); } return iccid; } std::optional> ChargePointConfiguration::getIMSI() { std::optional> imsi = std::nullopt; if (this->config["Internal"].contains("IMSI")) { - imsi.emplace(this->config["Internal"]["IMSI"]); + imsi.emplace(this->config["Internal"]["IMSI"].get()); } return imsi; } std::optional> ChargePointConfiguration::getMeterSerialNumber() { std::optional> meter_serial_number = std::nullopt; if (this->config["Internal"].contains("MeterSerialNumber")) { - meter_serial_number.emplace(this->config["Internal"]["MeterSerialNumber"]); + meter_serial_number.emplace(this->config["Internal"]["MeterSerialNumber"].get()); } return meter_serial_number; } std::optional> ChargePointConfiguration::getMeterType() { std::optional> meter_type = std::nullopt; if (this->config["Internal"].contains("MeterType")) { - meter_type.emplace(this->config["Internal"]["MeterType"]); + meter_type.emplace(this->config["Internal"]["MeterType"].get()); } return meter_type; }