2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 #ifndef FormDataList_h
22 #define FormDataList_h
24 #include "core/fileapi/Blob.h"
25 #include "platform/heap/Handle.h"
26 #include "platform/network/FormData.h"
27 #include "wtf/Forward.h"
28 #include "wtf/text/CString.h"
29 #include "wtf/text/TextEncoding.h"
33 class FormDataList : public RefCountedWillBeGarbageCollected<FormDataList> {
34 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(FormDataList);
37 ALLOW_ONLY_INLINE_ALLOCATION();
40 Item(const WTF::CString& data) : m_data(data) { }
41 Item(Blob* blob, const String& filename) : m_blob(blob), m_filename(filename) { }
43 const WTF::CString& data() const { return m_data; }
44 Blob* blob() const { return m_blob.get(); }
45 const String& filename() const { return m_filename; }
55 static PassRefPtrWillBeRawPtr<FormDataList> create(const WTF::TextEncoding& encoding)
57 return adoptRefWillBeNoop(new FormDataList(encoding));
60 typedef PersistentHeapVectorWillBeHeapVector<FormDataList::Item> FormDataListItems;
62 void appendData(const String& key, const String& value)
67 void appendData(const String& key, const CString& value)
72 void appendData(const String& key, int value)
75 appendString(String::number(value));
77 void appendBlob(const String& key, Blob* blob, const String& filename = String())
80 appendBlob(blob, filename);
83 const FormDataListItems& items() const { return m_items; }
84 const WTF::TextEncoding& encoding() const { return m_encoding; }
86 PassRefPtr<FormData> createFormData(FormData::EncodingType = FormData::FormURLEncoded);
87 PassRefPtr<FormData> createMultiPartFormData();
89 virtual void trace(Visitor*);
92 explicit FormDataList(const WTF::TextEncoding&);
95 void appendKeyValuePairItemsTo(FormData*, const WTF::TextEncoding&, bool isMultiPartForm, FormData::EncodingType = FormData::FormURLEncoded);
97 void appendString(const CString&);
98 void appendString(const String&);
99 void appendBlob(Blob*, const String& filename);
101 WTF::TextEncoding m_encoding;
102 FormDataListItems m_items;
107 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::FormDataList::Item);
109 #endif // FormDataList_h