Main Page   Class Hierarchy   Alphabetical List   Compound List   Examples  

fieldvalue.h

00001 /***************************************************************************
00002     copyright            : (C) 2002-2005 by Stefano Barbato
00003     email                : [email protected]
00004 
00005     $Id: fieldvalue_8h-source.html,v 1.4 2006-03-12 12:28:31 tat Exp $
00006  ***************************************************************************/
00007 
00008 /***************************************************************************
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU General Public License as published by  *
00012  *   the Free Software Foundation; either version 2 of the License, or     *
00013  *   (at your option) any later version.                                   *
00014  *                                                                         *
00015  ***************************************************************************/
00016 #ifndef _MIMETIC_RFC822_FIELDVALUE_H_
00017 #define _MIMETIC_RFC822_FIELDVALUE_H_
00018 #include <string>
00019 #include <mimetic/strutils.h>
00020 
00021 namespace mimetic
00022 {
00023 
00024 
00025 /// Value of an header field (base class)
00026 struct FieldValue
00027 {
00028     FieldValue();
00029     virtual ~FieldValue();
00030     virtual void set(const std::string& val) = 0;
00031     virtual std::string str() const = 0;
00032     virtual FieldValue* clone() const = 0;
00033     friend std::ostream& operator<<(std::ostream&, const FieldValue&);
00034 protected:
00035     friend class Rfc822Header;
00036     bool typeChecked() const;
00037     void typeChecked(bool);
00038 private:
00039     bool m_typeChecked;
00040 };
00041 
00042 /// Unstructured field value
00043 struct StringFieldValue: public FieldValue
00044 {
00045     StringFieldValue();
00046     StringFieldValue(const std::string&);
00047     void set(const std::string&);
00048     std::string str() const;
00049     const std::string& ref() const;
00050     std::string& ref();
00051 protected:
00052     FieldValue* clone() const;
00053 private:
00054     std::string m_value;
00055 };
00056 
00057 }
00058 
00059 #endif
00060