aboutsummaryrefslogtreecommitdiff
path: root/examples/cxx/hybrid/custom/wildcard/body.hxx
blob: 84a3eaf66804067c72378312f5fe14bee8f710a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// file      : examples/cxx/hybrid/custom/wildcard/body.hxx
// 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