diff options
author | Adrian Kummerländer | 2014-04-19 15:01:33 +0200 |
---|---|---|
committer | Adrian Kummerländer | 2014-04-19 15:01:33 +0200 |
commit | 334efe3383c436d61a8e5dd95b923cb0d5db9652 (patch) | |
tree | 591f2ab70e64fef5e74077000cfb010365fc5ce9 /src/utility.h | |
parent | 6c205f4859588fc8dad786dce5f2fa32c75fd3f3 (diff) | |
download | InputXSLT-334efe3383c436d61a8e5dd95b923cb0d5db9652.tar InputXSLT-334efe3383c436d61a8e5dd95b923cb0d5db9652.tar.gz InputXSLT-334efe3383c436d61a8e5dd95b923cb0d5db9652.tar.bz2 InputXSLT-334efe3383c436d61a8e5dd95b923cb0d5db9652.tar.lz InputXSLT-334efe3383c436d61a8e5dd95b923cb0d5db9652.tar.xz InputXSLT-334efe3383c436d61a8e5dd95b923cb0d5db9652.tar.zst InputXSLT-334efe3383c436d61a8e5dd95b923cb0d5db9652.zip |
Further code style fixes
* .. in the face of the planned development of usable external functions using the current proof-of-concept coding
* replaced usage of std::shared_ptr in FunctionReadXmlFile class with explicit implementation of default and copy constructor
* separated implementation and interfaces
Diffstat (limited to 'src/utility.h')
-rw-r--r-- | src/utility.h | 56 |
1 files changed, 6 insertions, 50 deletions
diff --git a/src/utility.h b/src/utility.h index 82f52aa..b841373 100644 --- a/src/utility.h +++ b/src/utility.h @@ -1,59 +1,15 @@ -#ifndef UTILITY_H_ -#define UTILITY_H_ +#ifndef INPUTXSLT_SRC_UTILITY_H_ +#define INPUTXSLT_SRC_UTILITY_H_ -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> - -#include <cstddef> -#include <cstdio> +#include <string> +namespace xalanc_1_11 { }; namespace xalan = xalanc_1_11; -namespace { - -const int OpenFlags = O_RDONLY; -const mode_t OpenMode = S_IRUSR | S_IWUSR; - -} - namespace InputXSLT { -std::string readFile(const std::string& path) { - int descriptor( - open(path.data(), OpenFlags, OpenMode) - ); - - if ( descriptor == -1 ) { - close(descriptor); - - return "io error"; - } else { - struct stat info; - fstat(descriptor, &info); - const std::size_t size(info.st_size); - - char* const buffer(new char[size]); - - ssize_t readSize(read( - descriptor, - static_cast<void*const>(buffer), - size - )); - - close(descriptor); - - std::string content( - buffer, - readSize - ); - - delete[] buffer; - - return content; - } -} +std::string readFile(const std::string&); } -#endif // UTILITY_H_ +#endif // INPUTXSLT_SRC_UTILITY_H_ |