即席で、それほど動作確認をできていませんが・・・
以下のような、FileRead_系関数をラッピングしたstreamクラスでは問題は解決しないでしょうか?
idxfstreamがifstreamのように使える(はず)です。
ifstreamと異なる点は、seekg時のポインタ初期位置の指定に、FileRead_seekと同じDXライブラリで定義された引数を利用する点ぐらいのはずです。
class dxfstreambuf:public std::streambuf{
protected:
int FileHandle;
public:
dxfstreambuf(char* FilePath){
FileHandle=FileRead_open(FilePath);
}
~dxfstreambuf(){FileRead_close(FileHandle);}
protected:
int xsgetn(char* c_p,std::streamsize size){
return FileRead_read(c_p,size,FileHandle);
}
int uflow(){return FileRead_getc(FileHandle);}
int pbackfail(int nCh){
FileRead_seek(FileHandle,-1,SEEK_CUR);
return 0;
}
int underflow(){
int ans=uflow();
FileRead_seek(FileHandle,-1,SEEK_CUR);
return ans;
}
public:
bool eof(){return FileRead_eof(FileHandle)!=0;}
int tellg(){return FileRead_tell(FileHandle);}
void seekg(int n){seekg(n,SEEK_SET);}
void seekg(int n,int origin){FileRead_seek(FileHandle,n,origin);}
};
class idxfstream:public std::istream{
private:
dxfstreambuf* streambuf;
std::_Uninitialized uninit;
public:
idxfstream():std::istream(uninit){streambuf=0;}
idxfstream(char* FilePath):std::istream(uninit){
streambuf=0;
open(FilePath);
}
~idxfstream(){close();}
void open(char* FilePath){
close();
streambuf= new dxfstreambuf(FilePath);
std::istream::init(streambuf);
}
void close(){
if(streambuf==0)return;
delete streambuf;
streambuf=0;
}
bool eof(){return streambuf->eof();}
bool is_open(){return streambuf!=0;}
pos_type tellg(){return streambuf->tellg();}
void seekg(pos_type n){return streambuf->seekg(n);}
void seekg(off_type n,int rel){return streambuf->seekg(n,rel);}
};