/
HttpCollection.h
67 lines (56 loc) · 1.88 KB
/
HttpCollection.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* HttpCollection.h
*
* Created on: Aug 9, 2012
* Author: lion
*/
#include "ifs/HttpCollection.h"
#include "QuickArray.h"
#ifndef HTTPCOLLECTION_H_
#define HTTPCOLLECTION_H_
namespace fibjs {
class HttpCollection : public HttpCollection_base {
public:
HttpCollection()
: m_count(0)
{
}
public:
// HttpCollection_base
virtual result_t clear();
virtual result_t has(exlib::string name, bool& retVal);
virtual result_t first(exlib::string name, Variant& retVal);
virtual result_t all(exlib::string name, obj_ptr<NArray>& retVal);
virtual result_t add(v8::Local<v8::Object> map);
virtual result_t add(exlib::string name, Variant value);
virtual result_t set(v8::Local<v8::Object> map);
virtual result_t set(exlib::string name, Variant value);
virtual result_t remove(exlib::string name);
virtual result_t _named_getter(exlib::string property, Variant& retVal);
virtual result_t _named_enumerator(v8::Local<v8::Array>& retVal);
virtual result_t _named_setter(exlib::string property, Variant newVal);
virtual result_t _named_deleter(exlib::string property, v8::Local<v8::Boolean>& retVal);
public:
void add(const char* name, int32_t szName, const char* value, int32_t szValue)
{
m_names[m_count].assign(name, szName);
m_values[m_count].assign(value, szValue);
m_count++;
}
void add(exlib::string& name, exlib::string& value)
{
m_names[m_count].assign(name);
m_values[m_count].assign(value);
m_count++;
}
size_t size();
size_t getData(char* buf, size_t sz);
result_t parse(exlib::string& str, const char* sep = "&", const char* eq = "=");
result_t parseCookie(exlib::string& str);
private:
QuickArray<exlib::string> m_names;
QuickArray<exlib::string> m_values;
int32_t m_count;
};
} /* namespace fibjs */
#endif /* HTTPCOLLECTION_H_ */