00001 /* -*-mode:c++; c-file-style: "gnu";-*- */ 00002 /* 00003 * $Id: FormFile_8cpp-source.html,v 1.1 2007/07/03 21:34:51 sebdiaz Exp $ 00004 * 00005 * Copyright (C) 1996 - 2004 Stephen F. Booth <sbooth@gnu.org> 00006 * 2007 Sebastien DIAZ <sebastien.diaz@gmail.com> 00007 * Part of the GNU cgicc library, http://www.gnu.org/software/cgicc 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 3 of the License, or (at your option) any later version. 00013 * 00014 * This library is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with this library; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA 00022 */ 00023 00024 #ifdef __GNUG__ 00025 # pragma implementation 00026 #endif 00027 00028 #include "cgicc/FormFile.h" 00029 #include "cgicc/CgiUtils.h" 00030 00031 cgicc::FormFile::FormFile(const std::string& name, 00032 const std::string& filename, 00033 const std::string& dataType, 00034 const std::string& data) 00035 : fName(name), 00036 fFilename(filename), 00037 fData(data) 00038 { 00039 fDataType = dataType.empty() ? std::string("text/plain") : dataType; 00040 } 00041 00042 bool 00043 cgicc::FormFile::operator== (const FormFile& file) const 00044 { 00045 return (stringsAreEqual(fName, file.fName) && 00046 stringsAreEqual(fFilename, file.fFilename) && 00047 stringsAreEqual(fDataType, file.fDataType)); 00048 } 00049 00050 cgicc::FormFile& 00051 cgicc::FormFile::operator= (const FormFile& file) 00052 { 00053 fName = file.fName; 00054 fFilename = file.fFilename; 00055 fDataType = file.fDataType; 00056 fData = file.fData; 00057 00058 return *this; 00059 } 00060 00061 void 00062 cgicc::FormFile::writeToStream(std::ostream& out) const 00063 { 00064 out.write(getData().data(), getDataLength()); 00065 }