Header.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2005-2007 by Peter Dimov.
00004 
00005 This file is part of Calitko (http://www.calitko.org).
00006 
00007 Calitko is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2 of the License, or
00010 (at your option) any later version.
00011 
00012 Calitko is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Calitko; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021 */
00022 
00023 #ifndef HTTP__HEADER_H
00024 #define HTTP__HEADER_H
00025 
00026 // Open containing namespaces:
00027 namespace Http {
00029 
00030 class HeaderPrivate;
00031 
00033 
00071 class Header
00072 {
00073 public:
00074                         Header();
00075                         Header (const Header &header);
00076                         Header (const QString &str);
00077     virtual             ~Header();
00078 
00079     Header &            operator= (const Header &h);
00080 
00081     bool                operator== (const Header &other) const;
00082     bool                operator!= (const Header &other) const;
00083 
00084     QString             fieldValue (const QString &fieldName) const;
00085     QStringList         fieldValues(const QString &fieldName) const;
00086     void                setFieldValue (const QString &fieldName,
00087                                        const QString &fieldValue);
00088     void                addFieldValue (const QString &fieldName,
00089                                        const QString &fieldValue);
00090     void                addFieldValues (const QString &fieldName,
00091                                         const QStringList &fieldValues);
00092     void                removeField (const QString &fieldName);
00093 
00094     QStringList         fields() const;
00095     bool                hasField (const QString &key) const;
00096 
00097     bool                parse (const QString &str);
00098     virtual QString     toString() const;
00099     bool                isValid() const;
00100 
00101 protected:
00102     virtual bool        parseLine (const QString &line, int number);
00103     void                setValid (bool);
00104 
00105 private:
00106     HeaderPrivate   *d;
00107     static QStringList splitStringIntoLines (const QString &str);
00108     bool parseAllLines (const QStringList& lines);
00109 };
00110 
00111 // Close containing namespaces:
00112 } // namespace Http
00114 
00115 #endif // HTTP__HEADER_H