diff options
author | lloyd <[email protected]> | 2009-12-01 14:59:01 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-12-01 14:59:01 +0000 |
commit | 9ffe4441271ff41fd33fc3965c191e62bce36453 (patch) | |
tree | 34ea31314e94c4d51271b9b09506a9aa03eff881 /doc/examples | |
parent | f3c149bce5b5ddb527a072c2f34daaa993cdba94 (diff) |
Update examples for changed/removed APIs, namely:
to_string -> std::to_string
system_time -> std::chrono
Diffstat (limited to 'doc/examples')
-rw-r--r-- | doc/examples/asn1.cpp | 4 | ||||
-rw-r--r-- | doc/examples/ca.cpp | 9 | ||||
-rw-r--r-- | doc/examples/gen_certs.cpp | 8 | ||||
-rw-r--r-- | doc/examples/rsa_manykey.cpp | 2 |
4 files changed, 14 insertions, 9 deletions
diff --git a/doc/examples/asn1.cpp b/doc/examples/asn1.cpp index 95757ec19..141d4d5b4 100644 --- a/doc/examples/asn1.cpp +++ b/doc/examples/asn1.cpp @@ -121,7 +121,7 @@ void decode(BER_Decoder& decoder, u32bit level) if((class_tag & APPLICATION) || (class_tag & CONTEXT_SPECIFIC) || (class_tag & PRIVATE)) { - name = "cons [" + to_string(type_tag) + "]"; + name = "cons [" + std::to_string(type_tag) + "]"; if(class_tag & APPLICATION) name += " appl"; @@ -148,7 +148,7 @@ void decode(BER_Decoder& decoder, u32bit level) Pipe pipe(((not_text) ? new Hex_Encoder : 0)); pipe.process_msg(bits); - emit("[" + to_string(type_tag) + "]", level, length, + emit("[" + std::to_string(type_tag) + "]", level, length, pipe.read_all_as_string()); } else if(type_tag == OBJECT_ID) diff --git a/doc/examples/ca.cpp b/doc/examples/ca.cpp index f5eccdde9..8be0fa527 100644 --- a/doc/examples/ca.cpp +++ b/doc/examples/ca.cpp @@ -56,8 +56,13 @@ int main(int argc, char* argv[]) // (this example should be extended to show how) // now sign the request - X509_Time start_time(system_time()); - X509_Time end_time(system_time() + 365 * 60 * 60 * 24); + auto now = std::chrono::system_clock::now(); + + X509_Time start_time(now); + + typedef std::chrono::duration<int, std::ratio<31556926>> years; + + X509_Time end_time(now + years(1)); X509_Certificate new_cert = ca.sign_request(req, rng, start_time, end_time); diff --git a/doc/examples/gen_certs.cpp b/doc/examples/gen_certs.cpp index 80cb5f54a..557c6f46e 100644 --- a/doc/examples/gen_certs.cpp +++ b/doc/examples/gen_certs.cpp @@ -71,14 +71,14 @@ void save_pair(const std::string& name, key_out.close(); } +typedef std::chrono::duration<int, std::ratio<31556926>> years; + int main() { - const u32bit seconds_in_a_year = 31556926; - - const u32bit current_time = system_time(); + auto current_time = std::chrono::system_clock::now(); X509_Time now = X509_Time(current_time); - X509_Time later = X509_Time(current_time + 4*seconds_in_a_year); + X509_Time later = X509_Time(current_time + years(4)); LibraryInitializer init; diff --git a/doc/examples/rsa_manykey.cpp b/doc/examples/rsa_manykey.cpp index 4122bc8ef..cf810749a 100644 --- a/doc/examples/rsa_manykey.cpp +++ b/doc/examples/rsa_manykey.cpp @@ -25,7 +25,7 @@ int main() RSA_PrivateKey key(rng, j); - std::ofstream priv(("rsa/" + to_string(j) + ".pem").c_str()); + std::ofstream priv(("rsa/" + std::to_string(j) + ".pem").c_str()); priv << PKCS8::PEM_encode(key); priv.close(); |