lean cpp library
A lean C++ library providing efficient utility classes for high-performance C++ applications.
file.h
00001 /*****************************************************/
00002 /* lean I/O                     (c) Tobias Zirr 2011 */
00003 /*****************************************************/
00004 
00005 // Opaque value requires this to go here
00006 #ifdef LEAN_INCLUDE_INLINED
00007     #ifndef LEAN_LOGGING_IO_FILE_CPP
00008         #define LEAN_LOGGING_IO_FILE_CPP
00009         #include "source/file.cpp"
00010     #endif
00011 #endif
00012 
00013 #ifndef LEAN_LOGGING_IO_FILE
00014 #define LEAN_LOGGING_IO_FILE
00015 
00016 #include "../lean.h"
00017 #include "../strings/types.h"
00018 #include "win_types.h"
00019 
00020 namespace lean
00021 {
00022 namespace io
00023 {
00024 
00026 class file
00027 {
00028 private:
00029     utf8_string m_name;
00030     windows_file_handle m_handle;
00031 
00032 public:
00034     enum access_modes
00035     {
00036         read = 0x1,                 
00037         write = 0x2,                
00038         readwrite = read | write    
00039     };
00041     enum share_modes
00042     {
00043         dont_share = 0x0,       
00044         share_default = 0x4,        
00045     };
00047     enum open_mode
00048     {
00049         create,         
00050         append,         
00051         open,           
00052         overwrite       
00053     };
00055     enum hints
00056     {
00057         none = 0x0,         
00058         sequential = 0x1,   
00059         random = 0x2        
00060     };
00061 
00063     LEAN_MAYBE_EXPORT explicit file(const utf8_ntri &name,
00064         uint4 access = read | write, open_mode mode = open,
00065         uint4 hints = none, uint4 share = share_default);
00067     LEAN_MAYBE_EXPORT virtual ~file();
00068     
00070     LEAN_MAYBE_EXPORT void pos(uint8 newPos);
00072     LEAN_MAYBE_EXPORT uint8 pos() const;
00073 
00075     LEAN_MAYBE_EXPORT void resize(uint8 newSize);
00076 
00078     LEAN_MAYBE_EXPORT uint8 revision() const;
00080     LEAN_MAYBE_EXPORT uint8 size() const;
00081 
00083     LEAN_INLINE windows_file_handle handle() const { return m_handle; };
00085     LEAN_INLINE const utf8_string& name() const { return m_name; };
00086 };
00087 
00088 } // namespace
00089 
00090 using io::file;
00091 
00092 } // namespace
00093 
00094 #endif