DCL 3.7.4
Loading...
Searching...
No Matches
StoredHttpFormData Class Reference

#include <HttpCollection.h>

Inheritance diagram for StoredHttpFormData:
HttpFormData Object

Public Member Functions

 StoredHttpFormData (const String &strTempDir)
virtual ~StoredHttpFormData ()
size_t size () const
bool isEmpty () const
FileInfoArray & operator[] (size_t _index)
FileInfoArray & byName (const wchar_t *_name)
Public Member Functions inherited from Object
virtual String toString () const
virtual void destroy ()
String className () const
bool isInstanceOf (const std::type_info &typeinfo) const
virtual const std::type_info & typeInfo () const

Protected Member Functions

virtual bool onFileStart (const PartHeader &header, void **ppCallbackData, String &strCallbackError)
virtual bool onFileData (const void *pData, size_t nSize, void *pCallbackData, String &strCallbackError)
virtual bool onFileEnd (const PartHeader &header, void *pCallbackData, bool bDataSuccess, String &strCallbackError)
Protected Member Functions inherited from Object
virtual ~Object ()
 Object ()

Detailed Description

Definition at line 313 of file HttpCollection.h.

Constructor & Destructor Documentation

◆ StoredHttpFormData()

StoredHttpFormData::StoredHttpFormData ( const String & strTempDir)

Definition at line 1110 of file HttpCollection.cpp.

1111{
1112 __DCL_ASSERT(!strTempDir.isEmpty());
1113
1114 __tempDir = strTempDir;
1115
1116 __handle = new PointerArray;
1117 __DCL_ASSERT(__handle != NULL);
1118}
#define NULL
Definition Config.h:312
#define __DCL_ASSERT(expr)
Definition Object.h:394

◆ ~StoredHttpFormData()

StoredHttpFormData::~StoredHttpFormData ( )
virtual

Definition at line 1120 of file HttpCollection.cpp.

1121{
1122 __DCL_ASSERT(__handle != NULL);
1123 PointerArray* p = __V();
1124 PointerArray& v = *p;
1125 for(size_t i = 0; i < v.size(); i++)
1126 delete (FileInfoArray*)v[i];
1127 v.clear();
1128 delete p;
1129}
#define __V()

Member Function Documentation

◆ byName()

StoredHttpFormData::FileInfoArray & StoredHttpFormData::byName ( const wchar_t * _name)

Definition at line 1151 of file HttpCollection.cpp.

1153{
1154 __DCL_ASSERT(_name != NULL && *_name != '\0');
1155
1156 FileInfoArray* pV = NULL;
1157 PointerArray& v = *(PointerArray*)__handle;
1158 for(size_t i = 0; i < v.size(); i++) {
1159 pV = (FileInfoArray*)(v[i]);
1160 if (pV->__name == _name)
1161 return *pV;
1162 }
1163
1164 pV = new FileInfoArray(_name);
1165 v.add(pV);
1166 return *pV;
1167}

◆ isEmpty()

bool StoredHttpFormData::isEmpty ( ) const

Definition at line 1137 of file HttpCollection.cpp.

1138{
1139 __DCL_ASSERT(__handle != NULL);
1140 return __V()->isEmpty();
1141}

◆ onFileData()

bool StoredHttpFormData::onFileData ( const void * pData,
size_t nSize,
void * pCallbackData,
String & strCallbackError )
protectedvirtual

Reimplemented from HttpFormData.

Definition at line 1231 of file HttpCollection.cpp.

1237{
1238 StoredCallbackData* cb = (StoredCallbackData*)pCallbackData;
1239 __DCL_ASSERT(cb != NULL);
1240
1241 try {
1242 cb->output->write(pData, nSize);
1243 cb->dataSize += nSize;
1244 }
1245 catch(IOException* e) {
1246 try {
1247 delete cb->output;
1249 }
1250 catch(IOException* e) {
1251 __DCL_TRACE1(L"%ls\n", e->toString().data());
1252 e->destroy();
1253 }
1254
1255 delete cb;
1256
1257 strCallbackError = e->toString();
1258 e->destroy();
1259 return false;
1260 }
1261 return true;
1262}
#define __DCL_TRACE1(fmt, arg1)
Definition Object.h:399
virtual void destroy()
Definition Exception.cpp:74
static void unlink(const String &_path) __DCL_THROWS1(IOException *)
Definition Files.cpp:97
virtual String toString() const
FileOutputStream * output

◆ onFileEnd()

bool StoredHttpFormData::onFileEnd ( const PartHeader & header,
void * pCallbackData,
bool bDataSuccess,
String & strCallbackError )
protectedvirtual

Reimplemented from HttpFormData.

Definition at line 1264 of file HttpCollection.cpp.

1270{
1271 StoredCallbackData* cb = (StoredCallbackData*)pCallbackData;
1272 __DCL_ASSERT(cb != NULL);
1273 try {
1274 delete cb->output;
1276 L"fileSize: %zd, dataSize: %zd\n",
1278 cb->dataSize
1279 );
1280 }
1281 catch(IOException* e) {
1282 try {
1284 }
1285 catch(IOException* e) {
1286 __DCL_TRACE1(L"%ls\n", e->toString().data());
1287 e->destroy();
1288 }
1289
1290 strCallbackError = e->toString();
1291 e->destroy();
1292 delete cb;
1293 return false;
1294 }
1295
1296 if (bDataSuccess) {
1297 FileInfo* pInfo = new FileInfo;
1298 __DCL_ASSERT(pInfo != NULL);
1299 pInfo->filename = header.filename;
1300 pInfo->contentType = header.contentType;
1301 pInfo->fileSize = cb->dataSize;
1302 pInfo->tempFilename = cb->tempFilename;
1303
1304 insert(header.name, pInfo);
1305 }
1306
1307 delete cb;
1308 return true;
1309}
#define __DCL_TRACE2_N(fmt, arg1, arg2)
static uint64_t size(const String &_path) __DCL_THROWS1(IOException *)
Definition Files.cpp:160

◆ onFileStart()

bool StoredHttpFormData::onFileStart ( const PartHeader & header,
void ** ppCallbackData,
String & strCallbackError )
protectedvirtual

Reimplemented from HttpFormData.

Definition at line 1189 of file HttpCollection.cpp.

1194{
1195 String filename;
1196 FileOutputStream* output = NULL;
1197 try {
1198 File* pFile = File::openTempFile(
1199 __tempDir,
1200 L"dclformdata"
1201 );
1202 output = new FileOutputStream(pFile);
1203 filename = pFile->path();
1204 }
1205 catch(IOException* e) {
1206 if (!filename.isEmpty()) {
1207 try {
1208 Files::unlink(filename);
1209 }
1210 catch (IOException* e) {
1211 __DCL_TRACE1(L"%ls\n", e->toString().data());
1212 e->destroy();
1213 }
1214 }
1215 strCallbackError = e->toString();
1216 e->destroy();
1217 return false;
1218 }
1219
1220 StoredCallbackData* cb = new StoredCallbackData;
1221 __DCL_ASSERT(cb != NULL);
1222 cb->tempFilename = filename;
1223 cb->output = output;
1224 cb->dataSize = 0;
1225
1226 *ppCallbackData = cb;
1227
1228 return true;
1229}
static File * openTempFile(const String &_dirname, const String &_prefix, unsigned int _mode=0666) __DCL_THROWS1(IOException *)
Definition File.cpp:727
const String & path() const
Definition File.h:251

◆ operator[]()

StoredHttpFormData::FileInfoArray & StoredHttpFormData::operator[] ( size_t _index)

Definition at line 1144 of file HttpCollection.cpp.

1145{
1146 __DCL_ASSERT(_index < __V()->size());
1147 return *((FileInfoArray*)((*__V())[_index]));
1148}

◆ size()

size_t StoredHttpFormData::size ( ) const

Definition at line 1131 of file HttpCollection.cpp.

1132{
1133 __DCL_ASSERT(__handle != NULL);
1134 return __V()->size();
1135}

The documentation for this class was generated from the following files: