📄 idb_streamc.i
字号:
static const int text;
filebuf();
filebuf(filedesc);
filebuf(filedesc, char *, int);
~filebuf();
filebuf* attach(filedesc);
filedesc fd() const { return (x_fd==-1) ? (-1) : x_fd; }
int is_open() const { return (x_fd!=-1); }
filebuf* open(const char *, int, int = filebuf::openprot);
filebuf* close();
int setmode(int = filebuf::text);
virtual int overflow(int=(-1));
virtual int underflow();
virtual streambuf* setbuf(char *, int);
virtual streampos seekoff(streamoff, ios::seek_dir, int);
virtual int sync();
private:
filedesc x_fd;
int x_fOpened;
};
class ifstream : public istream {
public:
ifstream();
ifstream(const char *, int =ios::in, int = filebuf::openprot);
ifstream(filedesc);
ifstream(filedesc, char *, int);
~ifstream();
streambuf * setbuf(char *, int);
filebuf* rdbuf() const { return (filebuf*) ios::rdbuf(); }
void attach(filedesc);
filedesc fd() const { return rdbuf()->fd(); }
int is_open() const { return rdbuf()->is_open(); }
void open(const char *, int =ios::in, int = filebuf::openprot);
void close();
int setmode(int mode = filebuf::text) { return rdbuf()->setmode(mode); }
};
class ofstream : public ostream {
public:
ofstream();
ofstream(const char *, int =ios::out, int = filebuf::openprot);
ofstream(filedesc);
ofstream(filedesc, char *, int);
~ofstream();
streambuf * setbuf(char *, int);
filebuf* rdbuf() const { return (filebuf*) ios::rdbuf(); }
void attach(filedesc);
filedesc fd() const { return rdbuf()->fd(); }
int is_open() const { return rdbuf()->is_open(); }
void open(const char *, int =ios::out, int = filebuf::openprot);
void close();
int setmode(int mode = filebuf::text) { return rdbuf()->setmode(mode); }
};
class fstream : public iostream {
public:
fstream();
fstream(const char *, int, int = filebuf::openprot);
fstream(filedesc);
fstream(filedesc, char *, int);
~fstream();
streambuf * setbuf(char *, int);
filebuf* rdbuf() const { return (filebuf*) ostream::rdbuf(); }
void attach(filedesc);
filedesc fd() const { return rdbuf()->fd(); }
int is_open() const { return rdbuf()->is_open(); }
void open(const char *, int, int = filebuf::openprot);
void close();
int setmode(int mode = filebuf::text) { return rdbuf()->setmode(mode); }
};
inline ios& binary(ios& _fstrm) \
{ ((filebuf*)_fstrm.rdbuf())->setmode(filebuf::binary); return _fstrm; }
inline ios& text(ios& _fstrm) \
{ ((filebuf*)_fstrm.rdbuf())->setmode(filebuf::text); return _fstrm; }
#pragma pack(pop)
#line 167 "D:/Progra~1/Micros~2/VC98/Include\\fstream.h"
#line 169 "D:/Progra~1/Micros~2/VC98/Include\\fstream.h"
#line 171 "D:/Progra~1/Micros~2/VC98/Include\\fstream.h"
#line 12 "D:/working/tools/isim\\misc.hpp"
#line 22 "D:/working/tools/isim\\misc.hpp"
typedef unsigned int uint;
typedef unsigned __int32 uint32;
#line 1 "D:/working/tools/isim\\vector.hpp"
#line 1 "D:/working/tools/isim\\error.hpp"
#line 1 "D:/working/tools/isim\\string.hpp"
#line 22 "D:/working/tools/isim\\error.hpp"
void __declspec(dllexport) _error(String file_name, int line_no, String msg);
#line 51 "D:/working/tools/isim\\error.hpp"
#line 60 "D:/working/tools/isim\\error.hpp"
#line 22 "D:/working/tools/isim\\vector.hpp"
#line 1 "D:/working/tools/isim\\libapi.hpp"
#line 23 "D:/working/tools/isim\\vector.hpp"
#pragma warning( disable : 4284 )
#pragma warning(disable: 4786)
template<class T> class vector;
template<class T>
class VPtr {
int idx;
vector<T> *v;
public:
VPtr(): idx(-1), v(0) {}
VPtr(const VPtr& p);
~VPtr() { idx = -1; v = 0; }
VPtr& operator=(const VPtr& p);
VPtr& operator++();
VPtr& operator--();
T& operator*();
T *operator->();
bool valid();
bool operator==(const VPtr& p);
bool operator!=(const VPtr& p);
bool operator<(const VPtr& p);
bool operator>(const VPtr& p);
friend class vector<T>;
};
struct __declspec(dllexport) portable_vector {
void *data;
int datasz;
int len;
portable_vector(): data(0), datasz(0), len(0) {}
void (*delop)(void*);
};
template<class T>
class vector {
T *data;
unsigned int sz;
unsigned int used;
void (*delop)(void*);
inline T *allocate(unsigned int n);
inline void destroy();
void copy(const vector& v);
public:
vector();
vector(const unsigned int n, const T& el = T());
vector(const vector& v);
vector(const portable_vector& pv);
~vector();
void clear_portable_vector(portable_vector& pv);
vector& operator=(const vector& v);
int size() const { return used; }
void clear();
T& back();
T& front();
void push_back(const T& el);
void push_back(const vector<T>& v);
T pop_back();
inline T& operator[](const unsigned int i);
inline const T& operator[](const unsigned int i) const;
VPtr<T> begin();
VPtr<T> end();
VPtr<T> getPtr(const unsigned int i);
operator portable_vector() const;
char* writeBin(const unsigned int bin_size);
char* readBin(unsigned int& bin_size);
friend class VPtr<T>;
};
#line 1 "D:/working/tools/isim\\vector.cpp"
#line 1 "D:/Progra~1/Micros~2/VC98/Include\\assert.h"
#line 17 "D:/Progra~1/Micros~2/VC98/Include\\assert.h"
#line 37 "D:/Progra~1/Micros~2/VC98/Include\\assert.h"
#line 69 "D:/Progra~1/Micros~2/VC98/Include\\assert.h"
#line 6 "D:/working/tools/isim\\vector.cpp"
#line 1 "D:/Progra~1/Micros~2/VC98/Include\\new.h"
#pragma once
#line 16 "D:/Progra~1/Micros~2/VC98/Include\\new.h"
#line 29 "D:/Progra~1/Micros~2/VC98/Include\\new.h"
#line 49 "D:/Progra~1/Micros~2/VC98/Include\\new.h"
typedef void (__cdecl * new_handler) ();
new_handler __cdecl set_new_handler(new_handler);
#line 72 "D:/Progra~1/Micros~2/VC98/Include\\new.h"
inline void *__cdecl operator new(size_t, void *_P)
{return (_P); }
inline void __cdecl operator delete(void *, void *)
{return; }
#line 81 "D:/Progra~1/Micros~2/VC98/Include\\new.h"
#line 82 "D:/Progra~1/Micros~2/VC98/Include\\new.h"
int __cdecl _query_new_mode( void );
int __cdecl _set_new_mode( int );
typedef int (__cdecl * _PNH)( size_t );
#line 95 "D:/Progra~1/Micros~2/VC98/Include\\new.h"
_PNH __cdecl _query_new_handler( void );
_PNH __cdecl _set_new_handler( _PNH );
#line 110 "D:/Progra~1/Micros~2/VC98/Include\\new.h"
#line 112 "D:/Progra~1/Micros~2/VC98/Include\\new.h"
#line 114 "D:/Progra~1/Micros~2/VC98/Include\\new.h"
#line 7 "D:/working/tools/isim\\vector.cpp"
template<class T>
VPtr<T>::VPtr(const VPtr& p)
{
idx = p.idx;
v = p.v;
}
template<class T>
VPtr<T>& VPtr<T>::operator=(const VPtr& p)
{
idx = p.idx;
v = p.v;
return *this;
}
template<class T>
VPtr<T>& VPtr<T>::operator++()
{
if (v)
{
((void)0);
idx++;
if (idx >= (int)v->used)
{
idx = -1;
v = 0;
}
}
return *this;
}
template<class T>
VPtr<T>& VPtr<T>::operator--()
{
if (v)
{
((void)0);
idx--;
if (idx < 0)
{
idx = -1;
v = 0;
}
}
return *this;
}
template<class T>
T& VPtr<T>::operator*()
{
if (v)
{
((void)0);
return v->data[idx];
}
((void)0);
return v->data[0];
}
template<class T>
T *VPtr<T>::operator->()
{
if (v)
{
((void)0);
return &(v->data[idx]);
}
((void)0);
return &(v->data[0]);
}
template<class T>
bool VPtr<T>::valid()
{
if (v)
{
((void)0);
if ((idx < 0) || (idx >= (int)v->used))
{
idx = -1;
v = 0;
return false;
}
return true;
}
return false;
}
template<class T>
bool VPtr<T>::operator==(const VPtr& p)
{
if (valid() && p.valid())
{
if (idx == p.idx)
return true;
else
return false;
}
return false;
}
template<class T>
bool VPtr<T>::operator!=(const VPtr& p)
{
return !(*this == p);
}
template<class T>
bool VPtr<T>::operator<(const VPtr& p)
{
valid();
p.valid();
((void)0);
return idx < p.idx;
}
template<class T>
bool VPtr<T>::operator>(const VPtr& p)
{
valid();
p.valid();
((void)0);
return idx > p.idx;
}
template<class T>
T *vector<T>::allocate(unsigned int n)
{
T *ptr = 0;
if (n > 0)
{
ptr = ((T *) operator new(n * sizeof(T)));
}
return ptr;
}
template<class T>
void vector<T>::destroy()
{
clear();
}
template<class T>
void vector<T>::copy(const vector& v)
{
sz = v.used;
used = v.used;
data = 0;
data = allocate(sz);
delop = &operator delete;
T *ptr = data;
for(unsigned int i=0; i<used; i++, ptr++)
ptr = new ((void *) ptr) T(v.data[i]);
}
template<class T>
vector<T>::vector()
{
sz = 0;
used = 0;
data = 0;
}
template<class T>
vector<T>::vector(const unsigned int n, const T& el)
{
sz = n;
used = n;
data = 0;
data = allocate(sz);
delop = &operator delete;
T *ptr = data;
for (unsigned int i=0; i<n; i++, ptr++)
ptr = new ((void *) ptr) T(el);
}
template<class T>
vector<T>::vector(const vector& v): data(0), sz(0), used(0)
{
copy(v);
}
template<class T>
vector<T>::vector(const portable_vector& pv)
{
((void)0);
sz = pv.len;
used = pv.len;
data = 0;
data = allocate(sz);
delop = &operator delete;
T *ptr = data;
T *el = (T *) pv.data;
for (unsigned int i=0; i<sz; i++, ptr++, el++)
ptr = new ((void *) ptr) T(*el);
}
template<class T>
vector<T>::~vector()
{
destroy();
sz = 0;
used = 0;
}
template<class T>
void vector<T>::clear_portable_vector(portable_vector& pv)
{
if (pv.data)
{
((void)0);
T *ptr = (T *)pv.data;
for (unsigned int i=0; i<pv.len; i++, ptr++)
ptr->~T();
pv.delop(pv.data);
pv.delop = 0;
}
pv.data = 0;
pv.datasz = 0;
pv.len = 0;
}
template<class T>
vector<T>& vector<T>::operator=(const vector& v)
{
destroy();
sz = 0;
used = 0;
copy(v);
return *this;
}
template<class T>
void vector<T>::clear()
{
T *ptr = data;
for (unsigned int i=0; i<used; i++, ptr++)
ptr->~T();
used = 0;
if (data) {
delop(data);
delop = &operator delete;
}
data = 0;
sz = 0;
}
template<class T>
T& vector<T>::back()
{
((void)0);
return data[used-1];
}
template<class T>
T& vector<T>::front()
{
((void)0);
return data[0];
}
template<class T>
void vector<T>::push_back(const T& el)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -