direct init structs

No need to deal with individual members

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2023-02-21 14:39:45 -08:00
parent 48caa32017
commit dd25d9999b
2 changed files with 14 additions and 22 deletions

View File

@ -923,9 +923,9 @@ class EXIV2API DateValue : public Value {
//! Simple Date helper structure
struct EXIV2API Date {
int32_t year{0}; //!< Year
int32_t month{0}; //!< Month
int32_t day{0}; //!< Day
int32_t year; //!< Year
int32_t month; //!< Month
int32_t day; //!< Day
};
//! @name Manipulators
@ -1014,13 +1014,11 @@ class EXIV2API TimeValue : public Value {
//! Simple Time helper structure
struct Time {
Time() = default;
int32_t hour{0}; //!< Hour
int32_t minute{0}; //!< Minute
int32_t second{0}; //!< Second
int32_t tzHour{0}; //!< Hours ahead or behind UTC
int32_t tzMinute{0}; //!< Minutes ahead or behind UTC
int32_t hour; //!< Hour
int32_t minute; //!< Minute
int32_t second; //!< Second
int32_t tzHour; //!< Hours ahead or behind UTC
int32_t tzMinute; //!< Minutes ahead or behind UTC
};
//! @name Manipulators

View File

@ -764,12 +764,11 @@ LangAltValue* LangAltValue::clone_() const {
}
DateValue::DateValue() : Value(date) {
date_ = {};
}
DateValue::DateValue(int32_t year, int32_t month, int32_t day) : Value(date) {
date_.year = year;
date_.month = month;
date_.day = day;
date_ = {year, month, day};
}
int DateValue::read(const byte* buf, size_t len, ByteOrder /*byteOrder*/) {
@ -813,9 +812,7 @@ int DateValue::read(const std::string& buf) {
}
void DateValue::setDate(const Date& src) {
date_.year = src.year;
date_.month = src.month;
date_.day = src.day;
date_ = src;
}
size_t DateValue::copy(byte* buf, ByteOrder /*byteOrder*/) const {
@ -883,14 +880,11 @@ Rational DateValue::toRational(size_t n) const {
}
TimeValue::TimeValue() : Value(time) {
time_ = {};
}
TimeValue::TimeValue(int32_t hour, int32_t minute, int32_t second, int32_t tzHour, int32_t tzMinute) : Value(date) {
time_.hour = hour;
time_.minute = minute;
time_.second = second;
time_.tzHour = tzHour;
time_.tzMinute = tzMinute;
time_ = {hour, minute, second, tzHour, tzMinute};
}
int TimeValue::read(const byte* buf, size_t len, ByteOrder /*byteOrder*/) {
@ -941,7 +935,7 @@ int TimeValue::read(const std::string& buf) {
/// \todo not used internally. At least we should test it
void TimeValue::setTime(const Time& src) {
std::memcpy(&time_, &src, sizeof(time_));
time_ = src;
}
size_t TimeValue::copy(byte* buf, ByteOrder /*byteOrder*/) const {