Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CheckOptions:
- key: readability-identifier-length.MinimumLoopCounterNameLength
value: 1
- key: readability-identifier-length.IgnoredVariableNames
value: "^[_defijkptuvw]$"
value: "^[_defijkptuvwxyz]$"
# More options here: https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-naming.html
- key: readability-identifier-naming.NamespaceCase
value: lower_case
Expand Down
64 changes: 33 additions & 31 deletions include/geode/basic/detail/geode_output_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,40 +35,42 @@
#include <geode/basic/logger.hpp>
#include <geode/basic/timer.hpp>

namespace geode
namespace geode::detail
{
namespace detail
template < typename Factory >
[[nodiscard]] std::unique_ptr< typename Factory::BaseClass >
geode_object_output_writer( std::string_view& filename )
{
template < typename Factory >
[[nodiscard]] std::unique_ptr< typename Factory::BaseClass >
geode_object_output_writer( std::string_view& filename )
filename = absl::StripAsciiWhitespace( filename );
const auto extension =
absl::AsciiStrToLower( extension_from_filename( filename ) );
OPENGEODE_EXCEPTION( Factory::has_creator( extension ),
"Unknown extension: ", extension );
return Factory::create(
extension, expand_predefined_folders( filename ) );
}

template < typename Factory, typename Object >
std::vector< std::string > geode_object_output_impl(
std::string_view type, const Object& object, std::string_view filename )
{
const Timer timer;
auto output = geode_object_output_writer< Factory >( filename );
const auto directories = filepath_without_filename( filename );
if( !directories.empty() )
{
filename = absl::StripAsciiWhitespace( filename );
const auto extension =
absl::AsciiStrToLower( extension_from_filename( filename ) );
OPENGEODE_EXCEPTION( Factory::has_creator( extension ),
"Unknown extension: ", extension );
return Factory::create(
extension, expand_predefined_folders( filename ) );
std::filesystem::create_directories( directories );
}

template < typename Factory, typename Object >
std::vector< std::string > geode_object_output_impl(
std::string_view type,
const Object& object,
std::string_view filename )
auto output_filenames = output->write( object );
std::string joined_filenames;
for( const auto& output_filename : output_filenames )
{
const Timer timer;
auto output = geode_object_output_writer< Factory >( filename );
const auto directories = filepath_without_filename( filename );
if( !directories.empty() )
{
std::filesystem::create_directories( directories );
}
auto result = output->write( object );
Logger::info(
type, " saved in ", filename, " in ", timer.duration() );
return result;
absl::StrAppend( &joined_filenames, output_filename, ", " );
}
} // namespace detail
} // namespace geode
joined_filenames.pop_back();
joined_filenames.pop_back();
Logger::info(
type, " saved in ", joined_filenames, " in ", timer.duration() );
return output_filenames;
}
} // namespace geode::detail
Loading