Main Page Class Hierarchy Alphabetical List Compound List Examples

field.h
1/***************************************************************************
2 copyright : (C) 2002-2008 by Stefano Barbato
3 email : stefano@codesink.org
4
5 $Id: field.h,v 1.14 2008-10-07 11:06:26 tat Exp $
6 ***************************************************************************/
7#ifndef _MIMETIC_RFC822_FIELD_H_
8#define _MIMETIC_RFC822_FIELD_H_
9#include <string>
10#include <mimetic/strutils.h>
11#include <mimetic/rfc822/fieldvalue.h>
12
13 namespace mimetic
14{
15
16
17
18/// Field class as defined by RFC822
19/**
20 Field class is a C++ representation of RFC822 \e header \e field.
21 Use this class when you need to create or parse messages' header fields.
22 Note that field name is case insensitive.
23
24 Parsing:
25 \code
26 Rfc822::Field f1("X-My-Field: some text(with a trailing comment)");
27 cout << f.name() << endl;
28 cout << f.value() << endl;
29 cout << f.value(true) << endl; // canonicalize (see RFC822)
30 \endcode
31
32 Building:
33 \code
34 Rfc822::Field f;
35 f.name("X-Unknown");
36 f.value("some text(with a trailing comment)");
37 cout << f;
38 \endcode
39
40 \sa <a href="../RFC/rfc822.txt">RFC822</a>
41 */
42 struct Field
43{
44 typedef mimetic::istring istring;
45 static const Field null;
46 Field();
47 Field(const std::string&);
48 Field(const std::string&, const std::string&);
49 ~Field();
50
51 Field(const Field&);
52 Field& operator=(const Field&);
53
54 void name(const std::string&);
55 const istring& name() const;
56
57 void value(const std::string&);
58 std::string value() const;
59
60 std::ostream& write(std::ostream&, unsigned int fold = 0) const;
61 friend std::ostream& operator<<(std::ostream&, const Field&);
62 private:
63 friend class Rfc822Header;
64 istring m_name;
65 FieldValue* m_pValue;
66};
67
68
69}
70#endif
mimetic
Definition body.h:18
mimetic::FieldValue
Value of an header field (base class).
Definition fieldvalue.h:18