6 #ifndef GRAMODS_CORE_STRINGFILE
7 #define GRAMODS_CORE_STRINGFILE
9 #include <gmCore/config.hh>
10 #include <gmCore/PreConditionViolation.hh>
17 BEGIN_NAMESPACE_GMCORE
30 if (file_ptr) fclose(*file_ptr);
38 if (!file_ptr) file_ptr = tmpfile();
55 while (!feof(*file_ptr)) {
56 if (fgets(buffer, 256, *file_ptr) == NULL)
break;
61 file_ptr = std::nullopt;
67 std::optional<FILE*> file_ptr;
Standard exception for violation of pre conditions in a call to a function or object.
Definition: PreConditionViolation.hh:16
This struct creates a FILE pointer to a temporary file and reads off this file's data into string whe...
Definition: StringFile.hh:24
~StringFile()
Closes the temporary file if this has not already been done.
Definition: StringFile.hh:29
FILE * getFilePtr()
Returns the FILE pointer to a temporary file after, if not already done, creating such a FILE object.
Definition: StringFile.hh:37
std::string finalize()
Rewinds and reads off the temporary file into a string, closes the FILE object and returns the string...
Definition: StringFile.hh:47