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"
36 ALLOW_ONLY_INLINE_ALLOCATION();
39 Item(const WTF::CString& data) : m_data(data) { }
40 Item(PassRefPtrWillBeRawPtr<Blob> blob, const String& filename) : m_blob(blob), m_filename(filename) { }
42 const WTF::CString& data() const { return m_data; }
43 Blob* blob() const { return m_blob.get(); }
44 const String& filename() const { return m_filename; }
50 RefPtrWillBeMember<Blob> m_blob;
54 FormDataList(const WTF::TextEncoding&);
56 void appendData(const String& key, const String& value)
61 void appendData(const String& key, const CString& value)
66 void appendData(const String& key, int value)
69 appendString(String::number(value));
71 void appendBlob(const String& key, PassRefPtrWillBeRawPtr<Blob> blob, const String& filename = String())
74 appendBlob(blob, filename);
77 const WillBeHeapVector<Item>& items() const { return m_items; }
78 const WTF::TextEncoding& encoding() const { return m_encoding; }
80 PassRefPtr<FormData> createFormData(FormData::EncodingType = FormData::FormURLEncoded);
81 PassRefPtr<FormData> createMultiPartFormData();
86 void appendKeyValuePairItemsTo(FormData*, const WTF::TextEncoding&, bool isMultiPartForm, FormData::EncodingType = FormData::FormURLEncoded);
88 void appendString(const CString&);
89 void appendString(const String&);
90 void appendBlob(PassRefPtrWillBeRawPtr<Blob>, const String& filename);
92 WTF::TextEncoding m_encoding;
93 WillBeHeapVector<Item> m_items;
98 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::FormDataList::Item);
100 #endif // FormDataList_h