diff options
author | Vincent Richard <[email protected]> | 2018-09-05 21:54:48 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2018-09-05 21:54:48 +0000 |
commit | b55bdc9c0bb68236aa2de0a8eaec9f4c80cc2769 (patch) | |
tree | efa18d623d3bc67c41d643aae145c16aa8f1006d /examples/example1.cpp | |
parent | Merge pull request #198 from xguerin/master (diff) | |
download | vmime-b55bdc9c0bb68236aa2de0a8eaec9f4c80cc2769.tar.gz vmime-b55bdc9c0bb68236aa2de0a8eaec9f4c80cc2769.zip |
Code style and clarity.
Diffstat (limited to 'examples/example1.cpp')
-rw-r--r-- | examples/example1.cpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/examples/example1.cpp b/examples/example1.cpp index b80fe636..c698fa7f 100644 --- a/examples/example1.cpp +++ b/examples/example1.cpp @@ -1,6 +1,6 @@ // // VMime library (http://www.vmime.org) -// Copyright (C) 2002-2013 Vincent Richard <[email protected]> +// Copyright (C) 2002 Vincent Richard <[email protected]> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as @@ -39,23 +39,20 @@ #include "vmime/platforms/posix/posixHandler.hpp" -int main() -{ +int main() { + std::cout << std::endl; // Set the global C and C++ locale to the user-configured locale. // The locale should use UTF-8 encoding for these tests to run successfully. - try - { + try { std::locale::global(std::locale("")); - } - catch (std::exception &) - { + } catch (std::exception &) { std::setlocale(LC_ALL, ""); } - try - { + try { + vmime::messageBuilder mb; // Fill in the basic fields @@ -74,9 +71,12 @@ int main() mb.setSubject(vmime::text("My first message generated with vmime::messageBuilder")); // Message body - mb.getTextPart()->setText(vmime::make_shared <vmime::stringContentHandler>( - "I'm writing this short text to test message construction " \ - "using the vmime::messageBuilder component.")); + mb.getTextPart()->setText( + vmime::make_shared <vmime::stringContentHandler>( + "I'm writing this short text to test message construction " \ + "using the vmime::messageBuilder component." + ) + ); // Construction vmime::shared_ptr <vmime::message> msg = mb.construct(); @@ -87,20 +87,21 @@ int main() vmime::utility::outputStreamAdapter out(std::cout); msg->generate(out); - } + // VMime exception - catch (vmime::exception& e) - { + } catch (vmime::exception& e) { + std::cout << "vmime::exception: " << e.what() << std::endl; throw; - } + // Standard exception - catch (std::exception& e) - { + } catch (std::exception& e) { + std::cout << "std::exception: " << e.what() << std::endl; - //throw; + throw; } std::cout << std::endl; -} + return 0; +} |