diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-07-25 08:56:48 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-07-25 08:56:48 +0200 |
commit | 098559ca3552ebd8f80a6d28254f4fa58913b751 (patch) | |
tree | 1eb6f65b492d3217a380a909f6810a5f3e00cc37 /butl/fdstream | |
parent | 6c8e3f09c185d7fa4664ccd9e5c4f623a17b84cc (diff) |
Add DLL export/import support
Diffstat (limited to 'butl/fdstream')
-rw-r--r-- | butl/fdstream | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/butl/fdstream b/butl/fdstream index bb14f25..0caac5c 100644 --- a/butl/fdstream +++ b/butl/fdstream @@ -10,6 +10,8 @@ #include <ostream> #include <cstdint> // uint16_t +#include <butl/export> + #include <butl/path> #include <butl/filesystem> // permissions @@ -38,7 +40,7 @@ namespace butl // used // - not movable, though can be easily supported // - class fdbuf: public std::basic_streambuf<char> + class LIBBUTL_EXPORT fdbuf: public std::basic_streambuf<char> { public: virtual @@ -111,10 +113,10 @@ namespace butl skip = 0x04 }; - fdstream_mode operator& (fdstream_mode, fdstream_mode); - fdstream_mode operator| (fdstream_mode, fdstream_mode); - fdstream_mode operator&= (fdstream_mode&, fdstream_mode); - fdstream_mode operator|= (fdstream_mode&, fdstream_mode); + inline fdstream_mode operator& (fdstream_mode, fdstream_mode); + inline fdstream_mode operator| (fdstream_mode, fdstream_mode); + inline fdstream_mode operator&= (fdstream_mode&, fdstream_mode); + inline fdstream_mode operator|= (fdstream_mode&, fdstream_mode); // Extended (compared to ios::openmode) file open flags. // @@ -132,12 +134,12 @@ namespace butl none = 0 // Usefull when build the mode incrementally. }; - fdopen_mode operator& (fdopen_mode, fdopen_mode); - fdopen_mode operator| (fdopen_mode, fdopen_mode); - fdopen_mode operator&= (fdopen_mode&, fdopen_mode); - fdopen_mode operator|= (fdopen_mode&, fdopen_mode); + inline fdopen_mode operator& (fdopen_mode, fdopen_mode); + inline fdopen_mode operator| (fdopen_mode, fdopen_mode); + inline fdopen_mode operator&= (fdopen_mode&, fdopen_mode); + inline fdopen_mode operator|= (fdopen_mode&, fdopen_mode); - class fdstream_base + class LIBBUTL_EXPORT fdstream_base { protected: fdstream_base () = default; @@ -180,7 +182,7 @@ namespace butl // Note that ifdstream destructor will close an open file descriptor but // will ignore any errors. To detect such errors, call close() explicitly. // - class ifdstream: fdstream_base, public std::istream + class LIBBUTL_EXPORT ifdstream: fdstream_base, public std::istream { public: // Create an unopened object with iostate = badbit | failbit (we cannot @@ -260,7 +262,7 @@ namespace butl // (std::uncaught_exception() == true). This is enforced with assert() in // the ofdstream destructor. // - class ofdstream: fdstream_base, public std::ostream + class LIBBUTL_EXPORT ofdstream: fdstream_base, public std::ostream { public: // Create an unopened object with iostate = badbit | failbit (we cannot @@ -344,7 +346,7 @@ namespace butl // - The fail and eof bits may be left cleared in the stream exception mask // when the function throws because of badbit. // - ifdstream& + LIBBUTL_EXPORT ifdstream& getline (ifdstream&, std::string&, char delim = '\n'); // Open a file returning the file descriptor on success and throwing @@ -363,21 +365,21 @@ namespace butl // process' umask, so effective permissions are permissions & ~umask. On // Windows permissions other than ru and wu are unlikelly to have effect. // - int + LIBBUTL_EXPORT int fdopen (const char*, fdopen_mode, permissions = permissions::ru | permissions::wu | permissions::rg | permissions::wg | permissions::ro | permissions::wo); - int + LIBBUTL_EXPORT int fdopen (const std::string&, fdopen_mode, permissions = permissions::ru | permissions::wu | permissions::rg | permissions::wg | permissions::ro | permissions::wo); - int + LIBBUTL_EXPORT int fdopen (const path&, fdopen_mode, permissions = permissions::ru | permissions::wu | @@ -387,15 +389,15 @@ namespace butl // Set the translation mode for the file descriptor. Return the previous // mode on success, throw ios::failure otherwise. // - fdstream_mode + LIBBUTL_EXPORT fdstream_mode fdmode (int, fdstream_mode); // Convenience functions for setting the translation mode for standard // streams. // - fdstream_mode stdin_fdmode (fdstream_mode); - fdstream_mode stdout_fdmode (fdstream_mode); - fdstream_mode stderr_fdmode (fdstream_mode); + LIBBUTL_EXPORT fdstream_mode stdin_fdmode (fdstream_mode); + LIBBUTL_EXPORT fdstream_mode stdout_fdmode (fdstream_mode); + LIBBUTL_EXPORT fdstream_mode stderr_fdmode (fdstream_mode); // Low-level, nothrow file descriptor API. // @@ -403,7 +405,7 @@ namespace butl // Close the file descriptor. Return true on success, set errno and return // false otherwise. // - bool + LIBBUTL_EXPORT bool fdclose (int) noexcept; // Open the null device (e.g., /dev/null) that discards all data written to @@ -412,7 +414,7 @@ namespace butl // Note that it's the caller's responsibility to close the returned file // descriptor. // - int + LIBBUTL_EXPORT int fdnull () noexcept; } |