Skip to content

Commit

Permalink
CiString conversion fixes for GCC<9 (#483)
Browse files Browse the repository at this point in the history
* CiString conversion fixes for GCC<9

---------

Signed-off-by: Kai-Uwe Hermann <[email protected]>
  • Loading branch information
hikinggrass authored Feb 21, 2024
1 parent 73b64e8 commit e401336
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion include/ocpp/common/cistring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ template <size_t L> class CiString : public String<L> {
CiString(const char* data) : String<L>(data) {
}

CiString(const CiString<L>& data) : String<L>(data.get()) {
}

/// \brief Creates a string
CiString() : String<L>() {
}
Expand All @@ -39,7 +42,7 @@ template <size_t L> class CiString : public String<L> {
}

/// \brief Conversion operator to turn a String into std::string
operator std::string() {
operator std::string() const {
return this->get();
}
};
Expand Down
16 changes: 8 additions & 8 deletions lib/ocpp/v16/charge_point_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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::string>());
}
std::optional<CiString<25>> ChargePointConfiguration::getChargePointSerialNumber() {
std::optional<CiString<25>> 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<std::string>());
}
return charge_point_serial_number;
}

CiString<20> ChargePointConfiguration::getChargePointVendor() {
return CiString<20>(this->config["Internal"]["ChargePointVendor"]);
return CiString<20>(this->config["Internal"]["ChargePointVendor"].get<std::string>());
}
CiString<50> ChargePointConfiguration::getFirmwareVersion() {
return CiString<50>(this->config["Internal"]["FirmwareVersion"]);
return CiString<50>(this->config["Internal"]["FirmwareVersion"].get<std::string>());
}
std::optional<CiString<20>> ChargePointConfiguration::getICCID() {
std::optional<CiString<20>> iccid = std::nullopt;
if (this->config["Internal"].contains("ICCID")) {
iccid.emplace(this->config["Internal"]["ICCID"]);
iccid.emplace(this->config["Internal"]["ICCID"].get<std::string>());
}
return iccid;
}
std::optional<CiString<20>> ChargePointConfiguration::getIMSI() {
std::optional<CiString<20>> imsi = std::nullopt;
if (this->config["Internal"].contains("IMSI")) {
imsi.emplace(this->config["Internal"]["IMSI"]);
imsi.emplace(this->config["Internal"]["IMSI"].get<std::string>());
}
return imsi;
}
std::optional<CiString<25>> ChargePointConfiguration::getMeterSerialNumber() {
std::optional<CiString<25>> 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<std::string>());
}
return meter_serial_number;
}
std::optional<CiString<25>> ChargePointConfiguration::getMeterType() {
std::optional<CiString<25>> 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<std::string>());
}
return meter_type;
}
Expand Down

0 comments on commit e401336

Please sign in to comment.