[Hdrflow-svn] SF.net SVN: hdrflow: [172] trunk/lib/openlibraries/src/openpluginlib/pl
Status: Pre-Alpha
Brought to you by:
glslang
|
From: <gl...@us...> - 2007-07-04 06:52:20
|
Revision: 172
http://hdrflow.svn.sourceforge.net/hdrflow/?rev=172&view=rev
Author: glslang
Date: 2007-07-03 23:52:17 -0700 (Tue, 03 Jul 2007)
Log Message:
-----------
+ eol-native
Modified Paths:
--------------
trunk/lib/openlibraries/src/openpluginlib/pl/stream.cpp
trunk/lib/openlibraries/src/openpluginlib/pl/stream.hpp
Property Changed:
----------------
trunk/lib/openlibraries/src/openpluginlib/pl/stream.cpp
trunk/lib/openlibraries/src/openpluginlib/pl/stream.hpp
Modified: trunk/lib/openlibraries/src/openpluginlib/pl/stream.cpp
===================================================================
--- trunk/lib/openlibraries/src/openpluginlib/pl/stream.cpp 2007-07-03 23:16:17 UTC (rev 171)
+++ trunk/lib/openlibraries/src/openpluginlib/pl/stream.cpp 2007-07-04 06:52:17 UTC (rev 172)
@@ -1,122 +1,122 @@
-
-// openpluginlib - A plugin interface to openlibraries.
-
-// Copyright (C) 2007 Goncalo Nuno M. de Carvalho
-// Released under the LGPL.
-// For more information, see http://www.cryogenicgraphics.com/hdrflow.
-
-#include <boost/filesystem/operations.hpp>
-
-#include <openpluginlib/pl/utf8_utils.hpp>
-#include <openpluginlib/pl/stream.hpp>
-
-namespace fs = boost::filesystem;
-
-namespace olib { namespace openpluginlib {
-
-stream::stream( const string& path, std::ios::openmode flags, std::size_t max_size )
- : data_( 0 )
- , offset_( 0 )
- , max_size_( max_size )
- , flags_( flags )
- , path_( path )
-{
- fs::path fs_path( path.c_str( ), fs::native );
- if( fs::exists( fs_path ) )
- {
- mapped_.open( fs_path.native_file_string( ), flags );
- if( mapped_.is_open( ) )
- {
- if( ( flags_ && std::ios::out ) != 0 )data_ = const_cast<char*>( mapped_.const_data( ) );
- else data_ = mapped_.data( );
-
- max_size_ = mapped_.size( );
- }
- }
-}
-
-stream::~stream( )
-{
- if( mapped_.is_open( ) )
- {
- data_ = 0;
- offset_ = 0;
- mapped_.close( );
- }
-}
-
-std::size_t stream::read( stream::pointer data, std::size_t bytes )
-{
- bytes = actual_bytes( bytes );
-
- memcpy( data, data_ + offset_, bytes );
- offset_ += bytes;
-
- return bytes;
-}
-
-std::size_t stream::write( stream::const_pointer data, std::size_t bytes )
-{
- bytes = actual_bytes( bytes );
-
- memcpy( data_ + offset_, data, bytes );
- offset_ += bytes;
-
- return bytes;
-}
-
-void stream::seek( std::size_t bytes, std::ios::seekdir flags )
-{
- if( flags == std::ios::beg )
- offset_ = bytes;
- else if( flags == std::ios::cur )
- offset_ += bytes;
- else if( flags == std::ios::end )
- offset_ = max_size_ - bytes;
-}
-
-std::size_t stream::getline( pointer data, std::size_t bytes )
-{
- bytes = actual_bytes( bytes );
-
- std::size_t i = 0;
- for( ; *( data_ + i ) != '\n' && i < bytes; ++i )
- *data++ = *( data_ + i );
-
- if( *( data_ + i ) == '\n' )
- ++i;
-
- offset_ += i;
-
- return bytes;
-}
-
-string stream::path( ) const
-{
- return fs::path( path_.c_str( ), fs::native ).native_file_string( );
-}
-
-wstring stream::wpath( ) const
-{
- return to_wstring( path( ) );
-}
-
-std::size_t stream::actual_bytes( std::size_t bytes ) const
-{
- if( offset_ + bytes > max_size_ )
- bytes = max_size_ - offset_;
-
- return bytes;
-}
-
-stream_ptr make_stream( const string& path, std::ios::openmode flags )
-{
- return stream_ptr( new stream( path, flags ) );
-}
-
-stream_ptr make_stream( void* data, std::ios::openmode flags )
-{
- return stream_ptr( new stream( static_cast<char*>( data ), flags ) );
-}
-
-} }
+
+// openpluginlib - A plugin interface to openlibraries.
+
+// Copyright (C) 2007 Goncalo Nuno M. de Carvalho
+// Released under the LGPL.
+// For more information, see http://www.cryogenicgraphics.com/hdrflow.
+
+#include <boost/filesystem/operations.hpp>
+
+#include <openpluginlib/pl/utf8_utils.hpp>
+#include <openpluginlib/pl/stream.hpp>
+
+namespace fs = boost::filesystem;
+
+namespace olib { namespace openpluginlib {
+
+stream::stream( const string& path, std::ios::openmode flags, std::size_t max_size )
+ : data_( 0 )
+ , offset_( 0 )
+ , max_size_( max_size )
+ , flags_( flags )
+ , path_( path )
+{
+ fs::path fs_path( path.c_str( ), fs::native );
+ if( fs::exists( fs_path ) )
+ {
+ mapped_.open( fs_path.native_file_string( ), flags );
+ if( mapped_.is_open( ) )
+ {
+ if( ( flags_ && std::ios::out ) != 0 )data_ = const_cast<char*>( mapped_.const_data( ) );
+ else data_ = mapped_.data( );
+
+ max_size_ = mapped_.size( );
+ }
+ }
+}
+
+stream::~stream( )
+{
+ if( mapped_.is_open( ) )
+ {
+ data_ = 0;
+ offset_ = 0;
+ mapped_.close( );
+ }
+}
+
+std::size_t stream::read( stream::pointer data, std::size_t bytes )
+{
+ bytes = actual_bytes( bytes );
+
+ memcpy( data, data_ + offset_, bytes );
+ offset_ += bytes;
+
+ return bytes;
+}
+
+std::size_t stream::write( stream::const_pointer data, std::size_t bytes )
+{
+ bytes = actual_bytes( bytes );
+
+ memcpy( data_ + offset_, data, bytes );
+ offset_ += bytes;
+
+ return bytes;
+}
+
+void stream::seek( std::size_t bytes, std::ios::seekdir flags )
+{
+ if( flags == std::ios::beg )
+ offset_ = bytes;
+ else if( flags == std::ios::cur )
+ offset_ += bytes;
+ else if( flags == std::ios::end )
+ offset_ = max_size_ - bytes;
+}
+
+std::size_t stream::getline( pointer data, std::size_t bytes )
+{
+ bytes = actual_bytes( bytes );
+
+ std::size_t i = 0;
+ for( ; *( data_ + i ) != '\n' && i < bytes; ++i )
+ *data++ = *( data_ + i );
+
+ if( *( data_ + i ) == '\n' )
+ ++i;
+
+ offset_ += i;
+
+ return bytes;
+}
+
+string stream::path( ) const
+{
+ return fs::path( path_.c_str( ), fs::native ).native_file_string( );
+}
+
+wstring stream::wpath( ) const
+{
+ return to_wstring( path( ) );
+}
+
+std::size_t stream::actual_bytes( std::size_t bytes ) const
+{
+ if( offset_ + bytes > max_size_ )
+ bytes = max_size_ - offset_;
+
+ return bytes;
+}
+
+stream_ptr make_stream( const string& path, std::ios::openmode flags )
+{
+ return stream_ptr( new stream( path, flags ) );
+}
+
+stream_ptr make_stream( void* data, std::ios::openmode flags )
+{
+ return stream_ptr( new stream( static_cast<char*>( data ), flags ) );
+}
+
+} }
Property changes on: trunk/lib/openlibraries/src/openpluginlib/pl/stream.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/lib/openlibraries/src/openpluginlib/pl/stream.hpp
===================================================================
--- trunk/lib/openlibraries/src/openpluginlib/pl/stream.hpp 2007-07-03 23:16:17 UTC (rev 171)
+++ trunk/lib/openlibraries/src/openpluginlib/pl/stream.hpp 2007-07-04 06:52:17 UTC (rev 172)
@@ -1,85 +1,85 @@
-
-// openpluginlib - A plugin interface to openlibraries.
-
-// Copyright (C) 2007 Goncalo Nuno M. de Carvalho
-// Released under the LGPL.
-// For more information, see http://www.cryogenicgraphics.com/hdrflow.
-
-#ifndef STREAM_INC_
-#define STREAM_INC_
-
-#ifdef _MSC_VER
-#pragma warning( push )
-#pragma warning( disable: 4251 )
-#endif
-
-#include <boost/shared_ptr.hpp>
-#include <boost/iostreams/device/mapped_file.hpp>
-
-#include <openpluginlib/pl/config.hpp>
-#include <openpluginlib/pl/string.hpp>
-
-namespace olib { namespace openpluginlib {
-
-class OPENPLUGINLIB_DECLSPEC stream
-{
-public:
- typedef char value_type;
- typedef value_type* pointer;
- typedef const value_type* const_pointer;
-
-public:
- explicit stream( pointer data = 0, std::ios::openmode flags = std::ios::in | std::ios::out, std::size_t max_size = 0 )
- : data_( data )
- , offset_( 0 )
- , max_size_( max_size )
- , flags_( flags )
- { }
-
- explicit stream( const string& path, std::ios::openmode flags = std::ios::in | std::ios::out, std::size_t max_size = 0 );
-
- ~stream( );
-
- std::size_t read( pointer data, std::size_t bytes );
- std::size_t write( const_pointer data, std::size_t bytes );
- void seek( std::size_t bytes, std::ios::seekdir flags );
- std::size_t getline( pointer data, std::size_t bytes );
-
- std::ios::openmode flags( ) const { return flags_; }
- bool is_null( ) const { return data_ == 0; }
- const char* data( ) const { return data_; }
- std::size_t offset( ) const { return offset_; }
- std::size_t max_size( ) const { return max_size_; }
-
- string path( ) const;
- wstring wpath( ) const;
-
-private:
- std::size_t actual_bytes( std::size_t bytes ) const;
-
-private:
- stream( const stream& );
- stream& operator=( const stream& );
-
-private:
- pointer data_;
- std::size_t offset_, max_size_;
- std::ios::openmode flags_;
- string path_;
-
-private:
- boost::iostreams::mapped_file mapped_;
-};
-
-typedef boost::shared_ptr<stream> stream_ptr;
-
-OPENPLUGINLIB_DECLSPEC stream_ptr make_stream( const string& path, std::ios::openmode flags );
-OPENPLUGINLIB_DECLSPEC stream_ptr make_stream( void* data, std::ios::openmode flags );
-
-} }
-
-#ifdef _MSC_VER
-#pragma warning( pop )
-#endif
-
-#endif
+
+// openpluginlib - A plugin interface to openlibraries.
+
+// Copyright (C) 2007 Goncalo Nuno M. de Carvalho
+// Released under the LGPL.
+// For more information, see http://www.cryogenicgraphics.com/hdrflow.
+
+#ifndef STREAM_INC_
+#define STREAM_INC_
+
+#ifdef _MSC_VER
+#pragma warning( push )
+#pragma warning( disable: 4251 )
+#endif
+
+#include <boost/shared_ptr.hpp>
+#include <boost/iostreams/device/mapped_file.hpp>
+
+#include <openpluginlib/pl/config.hpp>
+#include <openpluginlib/pl/string.hpp>
+
+namespace olib { namespace openpluginlib {
+
+class OPENPLUGINLIB_DECLSPEC stream
+{
+public:
+ typedef char value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+
+public:
+ explicit stream( pointer data = 0, std::ios::openmode flags = std::ios::in | std::ios::out, std::size_t max_size = 0 )
+ : data_( data )
+ , offset_( 0 )
+ , max_size_( max_size )
+ , flags_( flags )
+ { }
+
+ explicit stream( const string& path, std::ios::openmode flags = std::ios::in | std::ios::out, std::size_t max_size = 0 );
+
+ ~stream( );
+
+ std::size_t read( pointer data, std::size_t bytes );
+ std::size_t write( const_pointer data, std::size_t bytes );
+ void seek( std::size_t bytes, std::ios::seekdir flags );
+ std::size_t getline( pointer data, std::size_t bytes );
+
+ std::ios::openmode flags( ) const { return flags_; }
+ bool is_null( ) const { return data_ == 0; }
+ const char* data( ) const { return data_; }
+ std::size_t offset( ) const { return offset_; }
+ std::size_t max_size( ) const { return max_size_; }
+
+ string path( ) const;
+ wstring wpath( ) const;
+
+private:
+ std::size_t actual_bytes( std::size_t bytes ) const;
+
+private:
+ stream( const stream& );
+ stream& operator=( const stream& );
+
+private:
+ pointer data_;
+ std::size_t offset_, max_size_;
+ std::ios::openmode flags_;
+ string path_;
+
+private:
+ boost::iostreams::mapped_file mapped_;
+};
+
+typedef boost::shared_ptr<stream> stream_ptr;
+
+OPENPLUGINLIB_DECLSPEC stream_ptr make_stream( const string& path, std::ios::openmode flags );
+OPENPLUGINLIB_DECLSPEC stream_ptr make_stream( void* data, std::ios::openmode flags );
+
+} }
+
+#ifdef _MSC_VER
+#pragma warning( pop )
+#endif
+
+#endif
Property changes on: trunk/lib/openlibraries/src/openpluginlib/pl/stream.hpp
___________________________________________________________________
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|