CppCMS

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

http_file.h
1 //
3 // Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
4 //
5 // See accompanying file COPYING.TXT file for licensing details.
6 //
8 #ifndef CPPCMS_HTTP_FILE_H
9 #define CPPCMS_HTTP_FILE_H
10
11 #include <cppcms/defs.h>
12 #include <cppcms/cstdint.h>
13 #include <booster/hold_ptr.h>
14 #include <booster/nowide/fstream.h>
15 #include <booster/noncopyable.h>
16 #include <sstream>
17 #include <fstream>
18
19 namespace cppcms {
20
22 namespace impl { class multipart_parser; }
24
25 namespace http {
26
27 class request;
28
38 class CPPCMS_API file : public booster::noncopyable {
39 public:
43 std::string name() const;
47 std::string mime() const;
52 bool has_mime() const;
56 std::string filename() const;
57
62 std::istream &data();
63
67 long long size();
68
75 void output_file(std::string const &name,bool is_temporary = false);
76
81 void make_permanent();
89 int close();
90
100 void save_to(std::string const &filename);
101
103
104 void name(std::string const &);
105 void mime(std::string const &);
106 void filename(std::string const &);
107 std::ostream &write_data();
108
109 file();
110 ~file();
111
113
118 void set_memory_limit(size_t size);
123 void set_temporary_directory(std::string const &dir);
124
125
126 private:
127
128 std::string name_;
129 std::string mime_;
130 std::string filename_;
131 size_t size_limit_;
132
133 booster::nowide::fstream res1_;
134 std::stringstream res2_;
135 std::string res3_;
136 std::string res4_;
137
138 void save_by_copy(std::string const &file_name,std::istream &in);
139 void copy_stream(std::istream &in,std::ostream &out);
140
141
142 uint32_t removed_ : 1 ;
143 uint32_t file_specified_ : 1;
144 uint32_t file_temporary_: 1;
145 uint32_t reserverd_ : 29;
146
147 struct impl_data; // for future use
148 booster::hold_ptr<impl_data> d;
149 friend class request;
150 };
151
152
153 } } //::cppcms::http
154
155
156 #endif
booster::hold_ptr< impl_data >
cppcms
This is the namespace where all CppCMS functionality is placed.
Definition: application.h:19
cppcms::http::file
This class holds a uploaded file, it is generally fetched via widgets::file or via http::request::fil...
Definition: http_file.h:38
booster::noncopyable
This class makes impossible to copy any class derived from this one.
Definition: noncopyable.h:15
booster::nowide::fstream
basic_fstream< char > fstream
Definition: fstream.h:414
cppcms::http::request
This class represents all information related to the HTTP/CGI request.
Definition: http_request.h:37