From bce9d5a76072ec697ef69021818aa68709036da5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 16 Mar 2009 08:16:43 +0200 Subject: Add support for type customization in C++/Hybrid examples/cxx/hybrid/custom/wildcard/: new example --- examples/cxx/hybrid/custom/wildcard/body.hxx | 76 ++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 examples/cxx/hybrid/custom/wildcard/body.hxx (limited to 'examples/cxx/hybrid/custom/wildcard/body.hxx') diff --git a/examples/cxx/hybrid/custom/wildcard/body.hxx b/examples/cxx/hybrid/custom/wildcard/body.hxx new file mode 100644 index 0000000..504e3ca --- /dev/null +++ b/examples/cxx/hybrid/custom/wildcard/body.hxx @@ -0,0 +1,76 @@ +// file : examples/cxx/hybrid/custom/wildcard/body.hxx +// author : Boris Kolpackov +// copyright : not copyrighted - public domain + +#ifndef BODY_HXX +#define BODY_HXX + +#include "email.hxx" + +namespace email +{ + // Custom email body type which can hold text or binary. + // + class body + { + public: + enum type + { + type_none, + type_text, + type_binary + }; + + body () + : body_type_ (type_none), binary_ (0) + { + } + + ~body () + { + body_type (type_none); + } + + type + body_type () const + { + return body_type_; + } + + const std::string& + text () const + { + return text_; + } + + void + text (const std::string& t) + { + body_type (type_text); + text_ = t; + } + + const email::binary& + binary () const + { + return *binary_; + } + + void + binary (email::binary* b) + { + body_type (type_binary); + binary_ = b; + } + + private: + void + body_type (type t); + + type body_type_; + std::string text_; + email::binary* binary_; + }; +} + +#endif // BODY_HXX -- cgit v1.1