pleyo.com

/src/trunk2/BAL/Interfaces/FormData.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004, 2006 Apple Computer, Inc.
00003  * Copyright (C) 2007 Pleyo.
00004  * 
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public License
00016  * along with this library; see the file COPYING.LIB. If not, write to
00017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef FormData_h
00022 #define FormData_h
00023 
00024 #include "PlatformString.h"
00025 #include "Shared.h"
00026 #include <wtf/Vector.h>
00027 
00028 namespace WebCore {
00029 
00030 class FormDataElement {
00031 public:
00032     FormDataElement() : m_type(data) { }
00033     FormDataElement(const Vector<char>& array) : m_type(data), m_data(array) { }
00034     FormDataElement(const String& filename) : m_type(encodedFile), m_filename(filename) { }
00035 
00036     enum { data, encodedFile } m_type;
00037     Vector<char> m_data;
00038     String m_filename;
00039 };
00040 
00041 inline bool operator==(const FormDataElement& a, const FormDataElement& b)
00042 {
00043     if (&a == &b)
00044         return true;
00045     
00046     if (a.m_type != b.m_type)
00047         return false;
00048     if (a.m_data != b.m_data)
00049         return false;
00050     if (a.m_filename != b.m_filename)
00051         return false;
00052 
00053     return true;
00054 }
00055  
00056 inline bool operator!=(const FormDataElement& a, const FormDataElement& b)
00057 {
00058     return !(a == b);
00059 }
00060  
00061 class FormData : public Shared<FormData> {
00062 public:
00063     FormData() { } 
00064     FormData(const void* data, size_t);
00065     FormData(const CString&);
00066     PassRefPtr<FormData> copy() const;
00067     
00068     void appendData(const void* data, size_t);
00069     void appendFile(const String& filename);
00070 
00071     void flatten(Vector<char>&) const; // omits files
00072     String flattenToString() const; // omits files
00073 
00074     bool isEmpty() const { return m_elements.isEmpty(); }
00075     const Vector<FormDataElement>& elements() const { return m_elements; }
00076 
00077 private:
00078      FormData(const FormData&);
00079      
00080      Vector<FormDataElement> m_elements;
00081 };
00082 
00083 inline bool operator==(const FormData& a, const FormData& b)
00084 {
00085     return a.elements() == b.elements();
00086 }
00087 
00088 inline bool operator!=(const FormData& a, const FormData& b)
00089 {
00090     return a.elements() != b.elements();
00091 }
00092 
00093 } // namespace WebCore
00094 
00095 #endif

Generated on Wed Nov 21 20:04:17 2007 for Origyn Web Browser by Doxygen 1.5.3

pleyo.com
pleyo.com