void Message::MergeFrom(const Message& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_to()) { set_to(from.to()); } if (from.has_id()) { set_id(from.id()); } if (from.has_time()) { set_time(from.time()); } if (from.has_from()) { set_from(from.from()); } if (from.has_type()) { set_type(from.type()); } if (from.has_sn()) { set_sn(from.sn()); } if (from.has_data()) { set_data(from.data()); } if (from.has_expire()) { set_expire(from.expire()); } } }
Date(unsigned int y, unsigned int m, unsigned int d) { set_to(y, m, d); }
ZFILE::ZFILE(const Directory& dir, const String& path, const String& access_mode) : m_fp(NULL) { set_to(dir, path, access_mode); }
ZFILE::ZFILE(const Entry& entry, const String& access_mode) : m_fp(NULL) { set_to(entry, access_mode); }
ZFILE::ZFILE(const String& path, const String& access_mode) : m_fp(NULL) { set_to(path, access_mode); }
VectorView& operator=(const double val) { set_to(val); return *this; }
/* * Create an EAC_Time */ EAC_Time::EAC_Time(const std::string& t_spec, ASN1_Tag t) : tag(t) { set_to(t_spec); }
// assignment operator is not inherited SymmMatrix& operator=(const double val) { set_to(val); return *this; }
void X509_Time::decode_from(BER_Decoder& source) { BER_Object ber_time = source.get_next_object(); set_to(ASN1::to_string(ber_time), ber_time.type()); }
X509_Time::X509_Time(const std::string& t_spec, ASN1_Tag tag) { set_to(t_spec, tag); }
void X509_Time::set_to(const std::string& t_spec, ASN1_Tag spec_tag) { if(spec_tag == UTC_OR_GENERALIZED_TIME) { try { set_to(t_spec, GENERALIZED_TIME); return; } catch(Invalid_Argument&) {} // Not a generalized time. Continue try { set_to(t_spec, UTC_TIME); return; } catch(Invalid_Argument&) {} // Not a UTC time. Continue throw Invalid_Argument("Time string could not be parsed as GeneralizedTime or UTCTime."); } BOTAN_ASSERT(spec_tag == UTC_TIME || spec_tag == GENERALIZED_TIME, "Invalid tag."); if(t_spec.empty()) throw Invalid_Argument("Time string must not be empty."); if(t_spec.back() != 'Z') throw Unsupported_Argument("Botan does not support times with timezones other than Z: " + t_spec); if(spec_tag == GENERALIZED_TIME) { if(t_spec.size() != 15) throw Invalid_Argument("Invalid GeneralizedTime string: '" + t_spec + "'"); } else if(spec_tag == UTC_TIME) { if(t_spec.size() != 13) throw Invalid_Argument("Invalid UTCTime string: '" + t_spec + "'"); } const size_t YEAR_SIZE = (spec_tag == UTC_TIME) ? 2 : 4; std::vector<std::string> params; std::string current; for(size_t j = 0; j != YEAR_SIZE; ++j) current += t_spec[j]; params.push_back(current); current.clear(); for(size_t j = YEAR_SIZE; j != t_spec.size() - 1; ++j) { current += t_spec[j]; if(current.size() == 2) { params.push_back(current); current.clear(); } } m_year = to_u32bit(params[0]); m_month = to_u32bit(params[1]); m_day = to_u32bit(params[2]); m_hour = to_u32bit(params[3]); m_minute = to_u32bit(params[4]); m_second = (params.size() == 6) ? to_u32bit(params[5]) : 0; m_tag = spec_tag; if(spec_tag == UTC_TIME) { if(m_year >= 50) m_year += 1900; else m_year += 2000; } if(!passes_sanity_check()) throw Invalid_Argument("Time did not pass sanity check: " + t_spec); }