Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
Remove unused code from Filesystem.(h|c)pp
Unify replace_all and replace_all_nonrecursively in StringManip.hpp
  • Loading branch information
franzpoeschel committed Nov 22, 2018
1 parent 9b63e5f commit 757a9e0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1,590 deletions.
22 changes: 0 additions & 22 deletions include/openPMD/auxiliary/Filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,5 @@ remove_directory(std::string const& path);
*/
bool
remove_file(std::string const& path);

// /** Opens the file identified by the given path.
// *
// * @param path Absolute or relative path to the file to create.
// * @param accessType The access type.
// * If it is `CREATE` a new file is created and opened in write mode.
// * If it is `READ_WRITE`, an existing file is opened in read-write mode.
// * If it is `READ_ONLY`, an existing file is opened in read-only mode.
// * @return A file handle if the file was successfully opened or created,
// * a nullpointer otherwise.
// */
// FILEHANDLE
// open_file(std::string const& path, AccessType);

// /** Closes the file identified by the file handle.
// *
// * @param fileHandle The filehandle of the file to close.
// * @return True if closing was successful, false otherwise.
// */
// bool
// close_file(FILEHANDLE);

} // auxiliary
} // openPMD
15 changes: 1 addition & 14 deletions include/openPMD/auxiliary/StringManip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ replace_last(std::string s,
}

inline std::string
replace_all_nonrecursively(std::string s,
replace_all(std::string s,
std::string const& target,
std::string const& replacement)
{
Expand All @@ -124,19 +124,6 @@ replace_all_nonrecursively(std::string s,
return s;
}

inline std::string
replace_all(std::string s,
std::string const& target,
std::string const& replacement)
{
std::string::size_type pos;
while( (pos = s.find(target)) != std::string::npos )
s.replace(pos, target.size(), replacement);
s.shrink_to_fit();

return s;
}

inline std::vector< std::string >
split(std::string const &s,
std::string const &delimiter,
Expand Down
24 changes: 10 additions & 14 deletions src/IO/JSON/JSONIOHandlerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ namespace openPMD
""
);
}
auto expandedPath = auxiliary::replace_all_nonrecursively(
auto expandedPath = auxiliary::replace_all(
path,
"/",
"/subgroups/"
Expand Down Expand Up @@ -310,7 +310,7 @@ namespace openPMD

nlohmann::json * j = &obtainJsonContents( writable->parent );
std::string path;
auto extended = "/subgroups/" + auxiliary::replace_all_nonrecursively(
auto extended = "/subgroups/" + auxiliary::replace_all(
removeSlashes( parameters.path ),
"/",
"/subgroups/"
Expand Down Expand Up @@ -710,9 +710,8 @@ namespace openPMD
Parameter< Operation::READ_ATT > & parameters
)
{
// VERIFY_ALWAYS( writable->written,
// "Attributes have to be written before reading." )
// TODO ???
VERIFY_ALWAYS( writable->written,
"Attributes have to be written before reading." )
refreshFileFromParent( writable );
auto name = removeSlashes( parameters.name );
auto & jsonLoc = obtainJsonContents( writable )["attributes"];
Expand Down Expand Up @@ -746,9 +745,8 @@ namespace openPMD
Parameter< Operation::LIST_PATHS > & parameters
)
{
// VERIFY_ALWAYS( writable->written,
// "Values have to be written before reading a directory" );
// TODO ???
VERIFY_ALWAYS( writable->written,
"Values have to be written before reading a directory" );
auto & j = obtainJsonContents( writable )["subgroups"];
setAndGetFilePosition( writable );
refreshFileFromParent( writable );
Expand All @@ -767,9 +765,8 @@ namespace openPMD
Parameter< Operation::LIST_DATASETS > & parameters
)
{
// VERIFY_ALWAYS( writable->written,
// "Datasets have to be written before reading." )
// TODO ???
VERIFY_ALWAYS( writable->written,
"Datasets have to be written before reading." )
refreshFileFromParent( writable );
auto filePosition = setAndGetFilePosition( writable );
auto & j = obtainJsonContents( writable )["datasets"];
Expand All @@ -786,9 +783,8 @@ namespace openPMD
Parameter< Operation::LIST_ATTS > & parameters
)
{
// VERIFY_ALWAYS( writable->written,
// "Attributes have to be written before reading." )
// TODO ???
VERIFY_ALWAYS( writable->written,
"Attributes have to be written before reading." )
refreshFileFromParent( writable );
auto filePosition = setAndGetFilePosition( writable );
auto & j = obtainJsonContents( writable )["attributes"];
Expand Down
Loading

0 comments on commit 757a9e0

Please sign in to comment.