Main Page   Class Hierarchy   Alphabetical List   Compound List   Examples  

fieldvalue.h

00001 /***************************************************************************
00002     copyright            : (C) 2002-2008 by Stefano Barbato
00003     email                : stefano@codesink.org
00004 
00005     $Id: fieldvalue.h,v 1.13 2008-10-07 11:06:26 tat Exp $
00006  ***************************************************************************/
00007 #ifndef _MIMETIC_RFC822_FIELDVALUE_H_
00008 #define _MIMETIC_RFC822_FIELDVALUE_H_
00009 #include <string>
00010 #include <mimetic/strutils.h>
00011 
00012 namespace mimetic
00013 {
00014 
00015 
00016 /// Value of an header field (base class)
00017 struct FieldValue
00018 {
00019     FieldValue();
00020     virtual ~FieldValue();
00021     virtual void set(const std::string& val) = 0;
00022     virtual std::string str() const = 0;
00023     virtual FieldValue* clone() const = 0;
00024     friend std::ostream& operator<<(std::ostream&, const FieldValue&);
00025 protected:
00026     friend class Rfc822Header;
00027     bool typeChecked() const;
00028     void typeChecked(bool);
00029 private:
00030     bool m_typeChecked;
00031 };
00032 
00033 /// Unstructured field value
00034 struct StringFieldValue: public FieldValue
00035 {
00036     StringFieldValue();
00037     StringFieldValue(const std::string&);
00038     void set(const std::string&);
00039     std::string str() const;
00040     const std::string& ref() const;
00041     std::string& ref();
00042 protected:
00043     FieldValue* clone() const;
00044 private:
00045     std::string m_value;
00046 };
00047 
00048 }
00049 
00050 #endif
00051