[niepce] fwk: reformat files.{hpp,cpp} and exempi.hpp
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] fwk: reformat files.{hpp,cpp} and exempi.hpp
- Date: Thu, 1 Jun 2017 03:41:00 +0000 (UTC)
commit 900c06ffb80f428ae20ecead9c710d8d4eb6d4fe
Author: Hubert Figuière <hub figuiere net>
Date: Tue May 30 22:37:27 2017 -0400
fwk: reformat files.{hpp,cpp} and exempi.hpp
src/fwk/utils/exempi.hpp | 8 ++--
src/fwk/utils/files.cpp | 99 +++++++++++++++++++++------------------------
src/fwk/utils/files.hpp | 70 ++++++++++++++++----------------
3 files changed, 85 insertions(+), 92 deletions(-)
---
diff --git a/src/fwk/utils/exempi.hpp b/src/fwk/utils/exempi.hpp
index 8a7385c..4c1b990 100644
--- a/src/fwk/utils/exempi.hpp
+++ b/src/fwk/utils/exempi.hpp
@@ -48,7 +48,7 @@ void release(XmpFilePtr ptr)
xmp_files_free(ptr);
}
-inline
+inline
void release(XmpPtr ptr)
{
xmp_free(ptr);
@@ -59,7 +59,7 @@ void release(XmpPtr ptr)
* @todo move to Exempi.
*/
template <class T>
-class ScopedPtr
+class ScopedPtr
{
public:
NON_COPYABLE(ScopedPtr);
@@ -77,8 +77,8 @@ private:
extern const char * NIEPCE_XMP_NAMESPACE;
extern const char * NIEPCE_XMP_NS_PREFIX;
-extern const char * UFRAW_INTEROP_NAMESPACE;
-extern const char * UFRAW_INTEROP_NS_PREFIX;
+extern const char * UFRAW_INTEROP_NAMESPACE;
+extern const char * UFRAW_INTEROP_NS_PREFIX;
}
diff --git a/src/fwk/utils/files.cpp b/src/fwk/utils/files.cpp
index 878e50a..6e787f1 100644
--- a/src/fwk/utils/files.cpp
+++ b/src/fwk/utils/files.cpp
@@ -27,7 +27,6 @@
#include "files.hpp"
#include "pathutils.hpp"
-
namespace fwk {
std::string make_tmp_dir(const std::string& base)
@@ -46,75 +45,69 @@ std::string make_tmp_dir(const std::string& base)
return tmp_dir_path;
}
- bool filter_none(const Glib::RefPtr<Gio::FileInfo> & )
- {
- return true;
- }
+bool filter_none(const Glib::RefPtr<Gio::FileInfo> & )
+{
+ return true;
+}
- bool filter_ext(const Glib::RefPtr<Gio::FileInfo> & file, const std::string & ext)
- {
+bool filter_ext(const Glib::RefPtr<Gio::FileInfo> & file, const std::string & ext)
+{
std::string file_ext = fwk::path_extension(file->get_name());
boost::to_lower(file_ext);
if(file_ext == ext) {
- return false;
+ return false;
}
return true;
- }
+}
- bool filter_xmp_out(const Glib::RefPtr<Gio::FileInfo> & file)
- {
- static const std::string ext(".xmp");
- return filter_ext(file, ext);
- }
+bool filter_xmp_out(const Glib::RefPtr<Gio::FileInfo> & file)
+{
+ static const std::string ext(".xmp");
+ return filter_ext(file, ext);
+}
- FileList::FileList( const _impltype_t & v )
- : _impltype_t( v )
- {
- }
+FileList::FileList( const _impltype_t & v )
+ : _impltype_t( v )
+{
+}
- FileList::Ptr FileList::getFilesFromDirectory(const FileList::value_type & p, std::function<bool
(const Glib::RefPtr<Gio::FileInfo> &)> filter)
- {
+FileList::Ptr FileList::getFilesFromDirectory(const FileList::value_type& p, std::function<bool (const
Glib::RefPtr<Gio::FileInfo>&)> filter)
+{
// if(!exists( p ) ) {
// DBG_OUT( "directory %s do not exist", p.c_str() );
// return Ptr();
// }
- try
- {
- FileList::Ptr l( new FileList() );
-
- Glib::RefPtr<Gio::File> dir = Gio::File::create_for_path(p);
- Glib::RefPtr<Gio::FileEnumerator> enumerator = dir->enumerate_children();
-
- for( Glib::RefPtr<Gio::FileInfo> itr = enumerator->next_file();
- itr ; itr = enumerator->next_file() )
- {
- Gio::FileType ftype = itr->get_file_type();
- if ((ftype == Gio::FILE_TYPE_REGULAR) || (ftype ==
Gio::FILE_TYPE_SYMBOLIC_LINK))
- {
- if( filter(itr) ) {
- std::string fullname = Glib::build_filename(dir->get_path(), itr->get_name());
- l->push_back(fullname);
- DBG_OUT( "found file %s", fullname.c_str() );
- }
- }
- }
- enumerator->close();
- l->sort();
- return l;
- }
- catch(const Glib::Error & e)
- {
- ERR_OUT( "Exception: %s", e.what().c_str() );
+ try {
+ FileList::Ptr l(new FileList());
+
+ Glib::RefPtr<Gio::File> dir = Gio::File::create_for_path(p);
+ Glib::RefPtr<Gio::FileEnumerator> enumerator = dir->enumerate_children();
+
+ for (Glib::RefPtr<Gio::FileInfo> itr = enumerator->next_file();
+ itr ; itr = enumerator->next_file()) {
+ Gio::FileType ftype = itr->get_file_type();
+ if ((ftype == Gio::FILE_TYPE_REGULAR) || (ftype == Gio::FILE_TYPE_SYMBOLIC_LINK)) {
+ if (filter(itr)) {
+ std::string fullname =
+ Glib::build_filename(dir->get_path(), itr->get_name());
+ l->push_back(fullname);
+ DBG_OUT("found file %s", fullname.c_str());
+ }
+ }
+ }
+ enumerator->close();
+ l->sort();
+ return l;
+ } catch(const Glib::Error & e) {
+ ERR_OUT("Exception: %s", e.what().c_str());
+ } catch(const std::exception & e) {
+ ERR_OUT("Exception: %s", e.what());
}
- catch(const std::exception & e )
- {
- ERR_OUT( "Exception: %s", e.what() );
- }
- return Ptr();
- }
+ return Ptr();
+}
}
diff --git a/src/fwk/utils/files.hpp b/src/fwk/utils/files.hpp
index fc6c901..ca36219 100644
--- a/src/fwk/utils/files.hpp
+++ b/src/fwk/utils/files.hpp
@@ -34,46 +34,46 @@ namespace fwk {
/** wrapper around g_dir_make_tmp() */
std::string make_tmp_dir(const std::string& base);
- bool filter_none(const Glib::RefPtr<Gio::FileInfo> & file);
- bool filter_ext(const Glib::RefPtr<Gio::FileInfo> & file,
- const std::string & ext);
- bool filter_xmp_out(const Glib::RefPtr<Gio::FileInfo> & file);
+bool filter_none(const Glib::RefPtr<Gio::FileInfo> & file);
+bool filter_ext(const Glib::RefPtr<Gio::FileInfo> & file,
+ const std::string & ext);
+bool filter_xmp_out(const Glib::RefPtr<Gio::FileInfo> & file);
- class FileList
- : private std::list< std::string >
- {
- public:
- typedef std::shared_ptr< FileList > Ptr;
+class FileList
+ : private std::list<std::string>
+{
+public:
+ typedef std::shared_ptr< FileList > Ptr;
- typedef std::list< std::string > _impltype_t;
- typedef _impltype_t::value_type value_type;
- typedef _impltype_t::iterator iterator;
- typedef _impltype_t::const_iterator const_iterator;
- typedef _impltype_t::size_type size_type;
+ typedef std::list< std::string > _impltype_t;
+ typedef _impltype_t::value_type value_type;
+ typedef _impltype_t::iterator iterator;
+ typedef _impltype_t::const_iterator const_iterator;
+ typedef _impltype_t::size_type size_type;
- FileList( )
- {}
- FileList( const _impltype_t & );
+ FileList()
+ {}
+ FileList(const _impltype_t&);
- static Ptr getFilesFromDirectory(const value_type & dir,
- std::function<bool (const Glib::RefPtr<Gio::FileInfo> &)>
filter);
+ static Ptr getFilesFromDirectory(const value_type& dir,
+ std::function<bool (const Glib::RefPtr<Gio::FileInfo>&)> filter);
- const_iterator begin() const
- { return _impltype_t::cbegin(); }
- const_iterator end() const
- { return _impltype_t::cend(); }
- const_iterator cbegin() const
- { return _impltype_t::cbegin(); }
- const_iterator cend() const
- { return _impltype_t::cend(); }
- size_type size() const
- { return _impltype_t::size(); }
- void sort()
- { _impltype_t::sort(); }
- void push_back(const value_type & v)
- { _impltype_t::push_back(v); }
- };
-}
+ const_iterator begin() const
+ { return _impltype_t::cbegin(); }
+ const_iterator end() const
+ { return _impltype_t::cend(); }
+ const_iterator cbegin() const
+ { return _impltype_t::cbegin(); }
+ const_iterator cend() const
+ { return _impltype_t::cend(); }
+ size_type size() const
+ { return _impltype_t::size(); }
+ void sort()
+ { _impltype_t::sort(); }
+ void push_back(const value_type & v)
+ { _impltype_t::push_back(v); }
+};
+}
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]