00001 /* 00002 webEngine is the HTML processing library 00003 Copyright (C) 2009 Andrew Abramov aabramov@ptsecurity.ru 00004 00005 This file is part of webEngine 00006 00007 webEngineis free software: you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation, either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 webEngineis distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with webEngine. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 #ifndef __WEBLOB_H__ 00021 #define __WEBLOB_H__ 00022 #include <vector> 00023 #include "weTagScanner.h" 00024 00025 using namespace std; 00026 00036 class WeBlob : public vector<unsigned char> 00037 { 00038 public: 00039 WeBlob() { clear(); } 00040 ~WeBlob() { clear(); } 00041 00042 WeBlob(unsigned int cb) { clear(); resize(cb); zero(); } 00043 WeBlob(unsigned char* p, 00044 unsigned int cb) { clear(); assign(p, cb); } 00045 WeBlob(const WeBlob& b) { clear(); assign(b); } 00046 WeBlob(char* s) { clear(); assign(s); } 00047 00048 void zero() { vector<unsigned char>::assign(size(), 0); } 00049 void assign(unsigned char* p, 00050 unsigned int cb) { resize(cb); vector<unsigned char>::assign(p, p+cb); } 00051 void assign(const WeBlob& b) { vector<unsigned char>::assign(b.begin(), b.end()); } 00052 void assign(char* s) { vector<unsigned char>::assign(s, s + strlen(s)+1); } 00053 bool read(istream& file); 00054 bool write(ostream& file); 00055 WeInStream* stream(); 00056 template<class Archive> 00057 void serialize(Archive &ar, const unsigned int version); 00058 }; 00059 00070 class WeBlobStream : public WeInStream 00071 { 00072 const char* p; 00073 const char* start; 00074 const char* end; 00075 public: 00076 WeBlobStream(const WeBlob& src) 00077 { 00078 start = (const char*)&src.front(); 00079 end = (const char*)&src.back(); 00080 p = (char*)start; 00081 }; 00082 virtual char GetChar() { return p < end? *p++: 0; } 00083 virtual void PushBack(char c) {if(p > start) {p--;}} 00084 virtual int GetPos() { return p - start; }; 00085 }; 00086 00087 #endif //__WEBLOB_H__
©2009 Positive Technologies |
Generated on Tue Jul 14 18:27:30 2009 for WebEngine by |
|
1.5.7 |
|