From 334efe3383c436d61a8e5dd95b923cb0d5db9652 Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Sat, 19 Apr 2014 15:01:33 +0200 Subject: 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 --- src/utility.h | 56 ++++++-------------------------------------------------- 1 file changed, 6 insertions(+), 50 deletions(-) (limited to 'src/utility.h') 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 -#include -#include - -#include -#include +#include +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(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_ -- cgit v1.2.3