- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Search for |

# file.hpp

Go to the documentation of this file.

    00001 #ifndef SAGA_PACKAGES_DATA_FILE_FILE_HPP
    00002 #define SAGA_PACKAGES_DATA_FILE_FILE_HPP
    00003
    00004 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
    00005 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/file.hpp")
    00006 #endif
    00007 //  Copyright (c) 2005-2007 Andre Merzky (andre@merzky.net)
    00008 //  Copyright (c) 2005-2009 Hartmut Kaiser
    00009 //  Copyright (c) 2007 Ole Weidner (oweidner@cct.lsu.edu)
    00010 //
    00011 //  Distributed under the Boost Software License, Version 1.0. (See accompanying
    00012 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
    00013
    00014 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
    00015 #pragma wave option(output: null)
    00016 #endif
    00017
    00018 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
    00019 #pragma once
    00020 #endif
    00021
    00022 #include <string>
    00023
    00024 // include dependent spec sections
    00025 #include <saga/saga/util.hpp>
    00026 #include <saga/saga/base.hpp>
    00027 #include <saga/saga/types.hpp>
    00028 #include <saga/saga/session.hpp>
    00029 #include <saga/saga/call.hpp>
    00030
    00031 #include <saga/saga/packages/namespace/namespace_entry.hpp>
    00032 #include <saga/saga/packages/file/config.hpp>
    00033 #include <saga/saga/packages/file/iovec.hpp>
    00034
    00035 // suppress warnings about dependent classes not being exported from the dll
    00036 #if defined(BOOST_MSVC)
    00037 #pragma warning(push)
    00038 #pragma warning(disable: 4251 4231 4275 4660)
    00039 #endif
    00040
    00041 #ifdef SAGA_DEBUG
    00042 #include <saga/saga/packages/file/preprocessed/file.hpp>
    00043 #else
    00044
    00045 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
    00046 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/file.hpp")
    00047 #endif
    00049 namespace saga
    00050 {
    00057     namespace filesystem {
    00064     enum flags
    00065     {
    00066         Unknown         = /*  -1, */  saga::name_space::Unknown       ,
    00067         None            = /*   0, */  saga::name_space::None          ,
    00068         Overwrite       = /*   1, */  saga::name_space::Overwrite     ,
    00069         Recursive       = /*   2, */  saga::name_space::Recursive     ,
    00070         Dereference     = /*   4, */  saga::name_space::Dereference,
    00071         Create          = /*   8, */  saga::name_space::Create        ,
    00072         Exclusive       = /*  16, */  saga::name_space::Exclusive     ,
    00073         Lock            = /*  32, */  saga::name_space::Lock          ,
    00074         CreateParents   = /*  64, */  saga::name_space::CreateParents ,
    00075         Truncate        =    128,
    00076         Append          =    256,
    00077         Read            = /* 512, */  saga::name_space::Read,
    00078         Write           = /*1024, */  saga::name_space::Write,
    00079         ReadWrite       = /*Read | Write, */  saga::name_space::ReadWrite,
    00080         Binary          =   2048
    00081     };
    00082
    00087     enum seek_mode
    00088     {
    00089         Start = 1,
    00090         Current = 2,
    00091         End = 3
    00092     };
    00093
    00103     class SAGA_FILE_PACKAGE_EXPORT file
    00104       : public saga::name_space::entry
    00105     {
    00106
    00107     private:
    00109         // factory
    00110         SAGA_CALL_CREATE_PRIV_3(session const&, saga::url, int)
    00111
    00112
    00113         SAGA_CALL_PRIV_0 (get_size)
    00114         SAGA_CALL_PRIV_2 (read, saga::mutable_buffer, saga::ssize_t)
    00115         SAGA_CALL_PRIV_2 (write, saga::const_buffer, saga::ssize_t)
    00116         SAGA_CALL_PRIV_2 (seek, saga::off_t, seek_mode)
    00117
    00118         // scattered I/O
    00119         SAGA_CALL_PRIV_1 (read_v, std::vector<saga::filesystem::iovec>)
    00120         SAGA_CALL_PRIV_1 (write_v, std::vector<saga::filesystem::const_iovec>)
    00121
    00122         // pattern based I/O
    00123         SAGA_CALL_PRIV_1 (size_p, std::string)
    00124         SAGA_CALL_PRIV_2 (read_p, std::string, saga::mutable_buffer)
    00125         SAGA_CALL_PRIV_2 (write_p, std::string, saga::const_buffer)
    00126
    00127         // extended based I/O
    00128         SAGA_CALL_PRIV_0 (modes_e)
    00129         SAGA_CALL_PRIV_2 (size_e, std::string, std::string)
    00130         SAGA_CALL_PRIV_3 (read_e, std::string, std::string, saga::mutable_buffer)
    00131         SAGA_CALL_PRIV_3 (write_e, std::string, std::string, saga::const_buffer)
    00133
    00134     protected:
    00136
    00137         TR1::shared_ptr <saga::impl::file> get_impl_sp (void) const;
    00138         saga::impl::file* get_impl (void) const;
    00139         friend class saga::impl::file;
    00140         explicit file (saga::impl::file * init);
    00142
    00143     public:
    00148         file (session const& s, saga::url url, int mode = Read);
    00149
    00154         explicit file (saga::url url, int mode = Read);
    00155
    00160         explicit file (saga::object const& o);
    00161
    00166         file (void);
    00167
    00172         ~file (void);
    00173
    00177         static file create(session const & s, saga::url url, int mode = Read)
    00178         {
    00179             return file(s, url, mode);
    00180         }
    00181         SAGA_CALL_CREATE_3_DEF_1(session const&, saga::url, int, Read)
    00182
    00183
    00185         static file create(saga::url url, int mode = Read)
    00186         {
    00187             return file(url, mode);
    00188         }
    00189         template <typename Tag>
    00190         static saga::task create(saga::url url, int mode = Read)
    00191         {
    00192             return create<Tag>(detail::get_the_session(), url, mode);
    00193         }
    00194
    00199         file &operator= (saga::object const& o);
    00200
    00205         saga::off_t get_size(void)
    00206         {
    00207             saga::task t = get_sizepriv(saga::task_base::Sync());
    00208             return t.get_result<saga::off_t>();
    00209         }
    00210         SAGA_CALL_PUB_0_DEF_0(get_size)
    00211
    00212
    00221         saga::ssize_t read(saga::mutable_buffer buffer,
    00222             saga::ssize_t length = 0)
    00223         {
    00224             saga::task t = readpriv(buffer, length, saga::task_base::Sync());
    00225             return t.get_result<saga::ssize_t>();
    00226         }
    00227         SAGA_CALL_PUB_2_DEF_1(read, saga::mutable_buffer, saga::ssize_t, 0)
    00228
    00229
    00238         saga::ssize_t write(saga::const_buffer buffer,
    00239             saga::ssize_t length = 0)
    00240         {
    00241             saga::task t = writepriv(buffer, length, saga::task_base::Sync());
    00242             return t.get_result<saga::ssize_t>();
    00243         }
    00244         SAGA_CALL_PUB_2_DEF_1(write, saga::const_buffer, saga::ssize_t, 0)
    00245
    00246
    00254         saga::off_t seek(saga::off_t offset, seek_mode mode)
    00255         {
    00256             saga::task t = seekpriv(offset, mode, saga::task_base::Sync());
    00257             return t.get_result<saga::off_t>();
    00258         }
    00259         SAGA_CALL_PUB_2_DEF_0(seek, saga::off_t, seek_mode)
    00260
    00261
    00270         void read_v(std::vector<saga::filesystem::iovec> buffer_vec)
    00271         {
    00272             saga::task t = read_vpriv(buffer_vec, saga::task_base::Sync());
    00273             t.get_result ();
    00274         }
    00275         SAGA_CALL_PUB_1_DEF_0(read_v, std::vector<saga::filesystem::iovec>)
    00276
    00277
    00285         void write_v(std::vector<saga::filesystem::const_iovec> buffer_vec)
    00286         {
    00287             saga::task t = write_vpriv(buffer_vec, saga::task_base::Sync());
    00288             t.get_result ();
    00289         }
    00290         SAGA_CALL_PUB_1_DEF_0(write_v, std::vector<saga::filesystem::const_iovec>)
    00291
    00292
    00298         saga::ssize_t size_p(std::string pattern)
    00299         {
    00300             saga::task t = size_ppriv(pattern, saga::task_base::Sync());
    00301             return t.get_result<saga::ssize_t>();
    00302         }
    00303         SAGA_CALL_PUB_1_DEF_0(size_p, std::string)
    00304
    00305
    00313         saga::ssize_t read_p(std::string pattern, saga::mutable_buffer buffer)
    00314         {
    00315             saga::task t = read_ppriv(pattern, buffer, saga::task_base::Sync());
    00316             return t.get_result<saga::ssize_t>();
    00317         }
    00318         SAGA_CALL_PUB_2_DEF_0(read_p, std::string, saga::mutable_buffer)
    00319
    00320
    00328         saga::ssize_t write_p(std::string pattern, saga::const_buffer buffer)
    00329         {
    00330             saga::task t = write_ppriv(pattern, buffer, saga::task_base::Sync());
    00331             return t.get_result<saga::ssize_t>();
    00332         }
    00333         SAGA_CALL_PUB_2_DEF_0(write_p, std::string, saga::const_buffer)
    00334
    00335
    00343         std::vector<std::string> modes_e()
    00344         {
    00345             saga::task t = modes_epriv(saga::task_base::Sync());
    00346             return t.get_result<std::vector<std::string> >();
    00347         }
    00348         SAGA_CALL_PUB_0_DEF_0(modes_e)
    00349
    00350
    00355         saga::size_t size_e(std::string ext_mode, std::string specification)
    00356         {
    00357             saga::task t = size_epriv(ext_mode, specification, saga::task_base::Sync());
    00358             return t.get_result<saga::ssize_t>();
    00359         }
    00360         SAGA_CALL_PUB_2_DEF_0(size_e, std::string, std::string)
    00361
    00362
    00370         saga::ssize_t read_e(std::string ext_mode, std::string specification,
    00371             saga::mutable_buffer buffer)
    00372         {
    00373             saga::task t = read_epriv(ext_mode, specification, buffer,
    00374                 saga::task_base::Sync());
    00375             return t.get_result<saga::ssize_t>();
    00376         }
    00378         SAGA_CALL_PUB_3_DEF_0(read_e, std::string, std::string,
    00379             saga::mutable_buffer)
    00381
    00391         saga::ssize_t write_e(std::string ext_mode, std::string specification,
    00392             saga::const_buffer buffer)
    00393         {
    00394             saga::task t = write_epriv(ext_mode, specification, buffer,
    00395                 saga::task_base::Sync());
    00396             return t.get_result<saga::ssize_t>();
    00397         }
    00399         SAGA_CALL_PUB_3_DEF_0(write_e, std::string, std::string,
    00400             saga::const_buffer)
    00402
    00403
    00404     }; // class file
    00405
    00406     } // namespace file
    00407 } // namespace saga
    00408
    00409 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
    00410 #pragma wave option(output: null)
    00411 #endif
    00412 #endif // !defined(SAGA_DEBUG)
    00413
    00414 // re-enable warnings about dependent classes not being exported from the dll
    00415 #if defined(BOOST_MSVC)
    00416 #pragma warning(pop)
    00417 #endif
    00418
    00419 #endif // !defined(SAGA_PACKAGES_DATA_FILE_FILE_HPP)
    00420