30 #ifndef GENAPI_FILESTREAM_H_
31 #define GENAPI_FILESTREAM_H_
60 #if defined (_MSC_VER)
66 # if defined(GENICAM_FORCE_AUTO_IMPLIB) || (!defined(GENICAM_NO_AUTO_IMPLIB) && !defined(GENAPI_EXPORTS))
67 # if defined (_WIN32) && defined (_MT )
68 # pragma comment(lib, LIB_NAME( "GenApi" ))
70 # error Invalid configuration
76 #if defined (_MSC_VER)
77 # pragma warning(push)
78 # pragma warning (disable: 4251) // class 'GenApi::CPointer<T>' needs to have dll-interface to be used by clients of class 'GenICam::FileProtocolAdapter'
90 virtual bool openFile(
const char * pFileName, std::ios_base::openmode mode) = 0;
91 virtual bool closeFile(
const char * pFileName) = 0;
94 virtual int64_t getBufSize(
const char * pFileName, std::ios_base::openmode mode) = 0;
95 virtual bool deleteFile(
const char * pFileName) = 0;
147 virtual bool openFile(
const char * pFileName, std::ios_base::openmode mode);
160 virtual bool closeFile(
const char * pFileName);
223 virtual int64_t getBufSize(
const char * pFileName, std::ios_base::openmode mode);
236 virtual bool deleteFile(
const char * pFileName);
239 void WaitUntilFileOperationExecuteDone(
bool Validate =
true );
243 struct FileProtocolAdapterImpl;
244 FileProtocolAdapterImpl*
m_pImpl;
249 :
public std::basic_streambuf<CharType, Traits> {
257 using std::basic_streambuf<CharType, Traits>::gptr;
259 using std::basic_streambuf<CharType, Traits>::egptr;
261 using std::basic_streambuf<CharType, Traits>::eback;
263 using std::basic_streambuf<CharType, Traits>::gbump;
265 using std::basic_streambuf<CharType, Traits>::setg;
323 std::basic_streambuf<CharType, Traits>::_Init();
357 if (gptr() < egptr() )
358 return traits_type::to_int_type(*gptr());
361 return traits_type::eof();
363 return traits_type::to_int_type(*gptr());
368 if (gptr() != eback() || eback()<gptr()) {
370 if (!traits_type::eq_int_type(c, traits_type::eof() ) )
371 *(gptr()) =
static_cast<char_type>(traits_type::not_eof(c));
372 return traits_type::not_eof(c);
374 return traits_type::eof();
397 return GENICAM_NAMESPACE::INTEGRAL_CAST2<int, GenICam_streamsize>(retval);
409 :
public std::basic_streambuf<CharType, Traits> {
421 using std::basic_streambuf<CharType, Traits>::pbase;
423 using std::basic_streambuf<CharType, Traits>::pptr;
425 using std::basic_streambuf<CharType, Traits>::epptr;
427 using std::basic_streambuf<CharType, Traits>::pbump;
448 if (pAdapter->
attach( pInterface ))
450 if (pAdapter->
openFile( pFileName, mode ))
454 pBuffer =
new char_type[GENICAM_NAMESPACE::INTEGRAL_CAST<size_t>( bufSize ) /
sizeof(
char_type )];
457 std::basic_streambuf<CharType, Traits>::setp( pBuffer, pBuffer + bufSize );
488 bool syncFailed =
false;
513 if (n < epptr() - pptr() ) {
514 memcpy( pptr(), s, (
size_t)(n *
sizeof(
char_type)));
515 pbump( GENICAM_NAMESPACE::INTEGRAL_CAST2<int>(n) );
519 if (traits_type::eq_int_type(std::basic_streambuf<CharType, Traits>::sputc(s[i]), traits_type::eof()))
528 return traits_type::eof();
530 if (!traits_type::eq_int_type (c, traits_type::eof() ) )
531 return std::basic_streambuf<CharType, Traits>::sputc(
static_cast<char_type>(c));
533 return traits_type::not_eof(c);
538 return GENICAM_NAMESPACE::INTEGRAL_CAST<int>(
buffer_out());
548 int64_t cnt = pptr() - pbase();
560 pbump(- GENICAM_NAMESPACE::INTEGRAL_CAST<int>(cnt));
570 :
public std::basic_ostream<CharType, Traits> {
581 #if defined (_MSC_VER)
590 this->
open(pInterface, pFileName, mode);
594 #elif defined (__GNUC__)
600 ODevFileStreamBase(
GENAPI_NAMESPACE::INodeMap * pInterface,
const char * pFileName, std::ios_base::openmode mode = std::ios_base::out|std::ios_base::trunc)
603 this->
open(pInterface, pFileName, mode);
609 # error Unknown C++ library
636 std::ios_base::openmode mode = std::ios_base::out | std::ios_base::trunc) {
638 this->setstate(std::ios_base::failbit);
651 this->setstate(std::ios_base::failbit);
656 :
public std::basic_istream<CharType, Traits> {
668 #if defined (_MSC_VER)
675 std::ios_base::openmode mode = std::ios_base::in)
678 this->
open(pInterface, pFileName, mode);
682 #elif defined (__APPLE__)
689 std::ios_base::openmode mode = std::ios_base::in)
692 this->
open(pInterface, pFileName, mode);
696 #elif defined (__GNUC__)
703 std::ios_base::openmode mode = std::ios_base::in)
706 this->
open(pInterface, pFileName, mode);
711 # error Unknown C++ library
735 std::ios_base::openmode mode = std::ios_base::in) {
737 this->setstate(std::ios_base::failbit);
747 this->setstate(std::ios_base::failbit);
755 #if defined (_MSC_VER)
756 # pragma warning(pop)