diff options
author | Simon Warta <[email protected]> | 2015-08-08 17:20:35 +0200 |
---|---|---|
committer | Simon Warta <[email protected]> | 2015-08-11 10:50:14 +0200 |
commit | 3a85d9aa4da36e7ca46e370f4fe65dddc43f4172 (patch) | |
tree | 875edf108dc38536daa6dca1098493608ef78084 /src/lib/asn1/asn1_time.h | |
parent | 6dfe8a6e37aa19c59829d98ef47f4d497491be80 (diff) |
Remove string constructor of X509_Time()
* Break down string representations to to_string() and readable_string()
* Add m_ prefix to member variable names
* Fix order of methods
* Move comments Doxygen friendly to header
* Make set_to() private (future subjejt of refectoring); People should
use constructor
Closes #185
Diffstat (limited to 'src/lib/asn1/asn1_time.h')
-rw-r--r-- | src/lib/asn1/asn1_time.h | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/lib/asn1/asn1_time.h b/src/lib/asn1/asn1_time.h index 6200d7b62..f2b1c7975 100644 --- a/src/lib/asn1/asn1_time.h +++ b/src/lib/asn1/asn1_time.h @@ -22,24 +22,38 @@ class BOTAN_DLL X509_Time : public ASN1_Object void encode_into(class DER_Encoder&) const override; void decode_from(class BER_Decoder&) override; - std::string as_string() const; + /// Return an internal string representation of the time + std::string to_string() const; + + /// Returns a human friendly string replesentation of no particular formatting std::string readable_string() const; - bool time_is_set() const; - std::string to_string() const { return readable_string(); } + /// Return if the time has been set somehow + bool time_is_set() const; - s32bit cmp(const X509_Time&) const; + /// Compare this time against another + s32bit cmp(const X509_Time& other) const; - void set_to(const std::string&); - void set_to(const std::string&, ASN1_Tag); + /// Create an invalid X509_Time + X509_Time() {} + /// Create a X509_Time from a time point X509_Time(const std::chrono::system_clock::time_point& time); - X509_Time(const std::string& = ""); - X509_Time(const std::string&, ASN1_Tag); + + /// Create an X509_Time from string + X509_Time(const std::string& t_spec, ASN1_Tag tag); + private: + void set_to(const std::string& t_spec, ASN1_Tag); bool passes_sanity_check() const; - u32bit year, month, day, hour, minute, second; - ASN1_Tag tag; + + u32bit m_year = 0; + u32bit m_month = 0; + u32bit m_day = 0; + u32bit m_hour = 0; + u32bit m_minute = 0; + u32bit m_second = 0; + ASN1_Tag m_tag = NO_OBJECT; }; /* |