[niepce] Reindent clean
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] Reindent clean
- Date: Wed, 10 Apr 2013 02:53:08 +0000 (UTC)
commit c2bba1b8c9ecd31e7888d46f13285ebc00bfd2d8
Author: Hubert Figuière <hub figuiere net>
Date: Wed Feb 27 19:31:39 2013 -0500
Reindent clean
src/engine/db/library.cpp | 76 ++++++++++---------
src/engine/db/library.hpp | 174 +++++++++++++++++++++++----------------------
2 files changed, 128 insertions(+), 122 deletions(-)
---
diff --git a/src/engine/db/library.cpp b/src/engine/db/library.cpp
index 48c20c9..f97541c 100644
--- a/src/engine/db/library.cpp
+++ b/src/engine/db/library.cpp
@@ -62,7 +62,7 @@ Library::Library(const std::string & dir, const NotificationCenter::Ptr & nc)
m_dbdrv = m_dbmgr->connect_to_db(desc, "", "");
m_inited = init();
- m_dbdrv->create_function0("rewrite_xmp",
+ m_dbdrv->create_function0("rewrite_xmp",
boost::bind(&Library::triggerRewriteXmp,
this));
}
@@ -136,8 +136,8 @@ bool Library::_initDb()
SQLStatement initialFolders(
boost::format("insert into folders (name, locked, virtual, parent_id) "
- " values ('%1%', 1, %2%, 0)")
- % _("Trash")
+ " values ('%1%', 1, %2%, 0)")
+ % _("Trash")
% int(LibFolder::VIRTUAL_TRASH));
SQLStatement fileTable("CREATE TABLE files (id INTEGER PRIMARY KEY,"
" main_file INTEGER, name TEXT, parent_id INTEGER,"
@@ -203,9 +203,9 @@ int Library::checkDatabaseVersion()
std::string version;
try {
SQLStatement sql("SELECT value FROM admin WHERE key='version'");
-
+
if(m_dbdrv->execute_statement(sql)) {
- if(m_dbdrv->read_next_row()
+ if(m_dbdrv->read_next_row()
&& m_dbdrv->get_column_content(0, version)) {
v = boost::lexical_cast<int>(version);
}
@@ -234,7 +234,7 @@ int64_t Library::addFsFile(const std::string & file)
int64_t ret = -1;
SQLStatement sql(boost::format("INSERT INTO fsfiles (path)"
- " VALUES ('%1%')")
+ " VALUES ('%1%')")
% file);
if(m_dbdrv->execute_statement(sql)) {
int64_t id = m_dbdrv->last_row_id();
@@ -248,7 +248,7 @@ std::string Library::getFsFile(library_id_t id)
{
std::string p;
SQLStatement sql(boost::format("SELECT path FROM fsfiles"
- " WHERE id='%1%'")
+ " WHERE id='%1%'")
% id);
try {
if(m_dbdrv->execute_statement(sql) &&
@@ -275,7 +275,7 @@ library_id_t Library::addFile(library_id_t folder_id, const std::string & file,
try {
int32_t rating, orientation, flag;
library_id_t label_id;
- std::string label;
+ std::string label;
fwk::MimeType mime = fwk::MimeType(file);
eng::LibFile::FileType file_type = eng::LibFile::mimetype_to_filetype(mime);
fwk::XmpMeta meta(file, file_type == eng::LibFile::FILE_TYPE_RAW);
@@ -303,7 +303,7 @@ library_id_t Library::addFile(library_id_t folder_id, const std::string & file,
" '%4%', '%4%',"
" '%5%', '%6%', '%7%', '%8%', '%9%',"
" '%10%',"
- " ?1);")
+ " ?1);")
% fs_file_id % fwk::path_basename(file) % folder_id
% time(NULL)
% orientation % creation_date % rating
@@ -317,7 +317,7 @@ library_id_t Library::addFile(library_id_t folder_id, const std::string & file,
const std::vector< std::string > &keywords(meta.keywords());
std::vector< std::string >::const_iterator iter;
for(iter = keywords.begin();
- iter != keywords.end(); iter++)
+ iter != keywords.end(); iter++)
{
library_id_t kwid = makeKeyword(*iter);
if(kwid != -1) {
@@ -340,8 +340,9 @@ library_id_t Library::addFile(library_id_t folder_id, const std::string & file,
}
-library_id_t Library::addFileAndFolder(const std::string & folder, const std::string & file,
- bool manage)
+library_id_t Library::addFileAndFolder(const std::string & folder,
+ const std::string & file,
+ bool manage)
{
LibFolder::Ptr f;
f = getFolder(folder);
@@ -351,8 +352,9 @@ library_id_t Library::addFileAndFolder(const std::string & folder, const std::st
return addFile(f ? f->id() : -1, file, manage);
}
-library_id_t Library::addBundle(library_id_t folder_id, const eng::FileBundle::Ptr & bundle,
- bool manage)
+library_id_t Library::addBundle(library_id_t folder_id,
+ const eng::FileBundle::Ptr & bundle,
+ bool manage)
{
library_id_t file_id = 0;
file_id = addFile(folder_id, bundle->main_file(), manage);
@@ -371,16 +373,17 @@ library_id_t Library::addBundle(library_id_t folder_id, const eng::FileBundle::P
fsfile_id = addFsFile(bundle->jpeg());
if(fsfile_id > 0) {
success = addJpegFileToBundle(file_id, fsfile_id);
- }
+ }
}
}
return file_id;
}
-bool Library::addSidecarFileToBundle(library_id_t file_id, library_id_t fsfile_id)
+bool Library::addSidecarFileToBundle(library_id_t file_id,
+ library_id_t fsfile_id)
{
SQLStatement sql(boost::format("UPDATE files SET xmp_file='%2%'"
- " WHERE id='%1%';")
+ " WHERE id='%1%';")
% file_id % fsfile_id);
try {
return m_dbdrv->execute_statement(sql);
@@ -397,7 +400,7 @@ bool Library::addJpegFileToBundle(library_id_t file_id, library_id_t fsfile_id)
{
SQLStatement sql(boost::format("UPDATE files SET jpeg_file='%2%',"
" file_type='%3%' "
- " WHERE id='%1%';")
+ " WHERE id='%1%';")
% file_id % fsfile_id % LibFile::FILE_TYPE_RAW_JPEG);
try {
return m_dbdrv->execute_statement(sql);
@@ -414,9 +417,9 @@ LibFolder::Ptr Library::getFolder(const std::string & folder)
{
LibFolder::Ptr f;
SQLStatement sql(boost::format("SELECT %1% "
- "FROM folders WHERE path='%2%'")
+ "FROM folders WHERE path='%2%'")
% LibFolder::read_db_columns() % folder);
-
+
try {
if(m_dbdrv->execute_statement(sql)) {
if(m_dbdrv->read_next_row()) {
@@ -437,13 +440,13 @@ LibFolder::Ptr Library::addFolder(const std::string & folder)
LibFolder::Ptr f;
SQLStatement sql(boost::format("INSERT INTO folders "
"(path,name,vault_id,parent_id) "
- "VALUES('%1%', '%2%', '0', '0')")
+ "VALUES('%1%', '%2%', '0', '0')")
% folder % fwk::path_basename(folder));
try {
if(m_dbdrv->execute_statement(sql)) {
library_id_t id = m_dbdrv->last_row_id();
DBG_OUT("last row inserted %Ld", (long long)id);
- f = LibFolder::Ptr(new LibFolder(id,
+ f = LibFolder::Ptr(new LibFolder(id,
fwk::path_basename(folder)));
}
}
@@ -541,7 +544,7 @@ int Library::countFolder(library_id_t folder_id)
if(m_dbdrv->read_next_row()) {
m_dbdrv->get_column_content(0, count);
}
- }
+ }
}
catch(fwk::Exception & e)
{
@@ -569,7 +572,7 @@ void Library::getAllKeywords(const Keyword::ListPtr & l)
DBG_OUT("db exception %s", e.what());
}
}
-
+
library_id_t Library::makeKeyword(const std::string & keyword)
{
library_id_t keyword_id = -1;
@@ -612,7 +615,7 @@ bool Library::assignKeyword(library_id_t kw_id, library_id_t file_id)
{
bool ret = false;
SQLStatement sql(boost::format("INSERT INTO keywording (file_id, keyword_id) "
- " VALUES('%1%', '%2%');")
+ " VALUES('%1%', '%2%');")
% file_id % kw_id );
try {
ret = m_dbdrv->execute_statement(sql);
@@ -713,22 +716,22 @@ bool Library::setMetaData(library_id_t file_id, const LibMetadata::Ptr & meta)
DBG_OUT("db exception %s", e.what());
ret = false;
}
- return ret;
+ return ret;
}
-/** set metadata
+/** set metadata
* @param file_id the file ID to set the metadata block
* @param meta the metadata index
* @param value the value to set
* @return false on error
*/
-bool Library::setMetaData(library_id_t file_id, fwk::PropertyIndex meta,
+bool Library::setMetaData(library_id_t file_id, fwk::PropertyIndex meta,
const fwk::PropertyValue & value)
{
bool retval = false;
DBG_OUT("setting metadata %x", meta);
- DBG_ASSERT(check_property_type(meta, value.type()),
+ DBG_ASSERT(check_property_type(meta, value.type()),
"wrong property value type");
switch(meta) {
case eng::NpXmpRatingProp:
@@ -762,7 +765,7 @@ bool Library::setMetaData(library_id_t file_id, fwk::PropertyIndex meta,
default:
// external
// TODO add the external metadata
- //
+ //
break;
}
LibMetadata::Ptr metablock(new LibMetadata(file_id));
@@ -835,16 +838,18 @@ library_id_t Library::addLabel(const std::string & name, const std::string & col
}
-library_id_t Library::addLabel(const std::string & name, const fwk::RgbColour & c)
+library_id_t Library::addLabel(const std::string & name,
+ const fwk::RgbColour & c)
{
return addLabel(name, c.to_string());
}
-bool Library::updateLabel(library_id_t label_id, const std::string & name, const std::string & colour)
+bool Library::updateLabel(library_id_t label_id, const std::string & name,
+ const std::string & colour)
{
SQLStatement sql(boost::format("UPDATE labels SET name='%2%', color='%3%'"
- " WHERE id='%1%';")
+ " WHERE id='%1%';")
% label_id % name % colour);
try {
return m_dbdrv->execute_statement(sql);
@@ -859,7 +864,6 @@ bool Library::updateLabel(library_id_t label_id, const std::string & name, const
bool Library::deleteLabel(library_id_t label_id)
{
-
SQLStatement sql(boost::format("DELETE FROM labels "
" WHERE id='%1%';") % label_id);
try {
@@ -901,8 +905,8 @@ bool Library::rewriteXmpForId(library_id_t id, bool write_xmp)
SQLStatement getxmp(boost::format("SELECT xmp, main_file, xmp_file FROM files "
" WHERE id='%1%';") % id);
try {
-
- if(m_dbdrv->execute_statement(del)
+
+ if(m_dbdrv->execute_statement(del)
&& m_dbdrv->execute_statement(getxmp)) {
while(write_xmp && m_dbdrv->read_next_row()) {
std::string xmp_buffer;
diff --git a/src/engine/db/library.hpp b/src/engine/db/library.hpp
index 97a2bdc..7c82366 100644
--- a/src/engine/db/library.hpp
+++ b/src/engine/db/library.hpp
@@ -51,9 +51,9 @@ namespace eng {
class Library
{
public:
- typedef std::tr1::shared_ptr<Library> Ptr;
+ typedef std::tr1::shared_ptr<Library> Ptr;
- typedef enum {
+ typedef enum {
NOTIFY_NONE = 0,
NOTIFY_NEW_LIBRARY_CREATED,
NOTIFY_ADDED_FOLDERS,
@@ -71,34 +71,34 @@ public:
NOTIFY_FOLDER_COUNTED,
NOTIFY_FOLDER_COUNT_CHANGE,
NOTIFY_FILE_MOVED
- } NotifyType;
+ } NotifyType;
- Library(const std::string & dir, const fwk::NotificationCenter::Ptr & nc);
- virtual ~Library();
+ Library(const std::string & dir, const fwk::NotificationCenter::Ptr & nc);
+ virtual ~Library();
- bool ok()
+ bool ok()
{ return m_inited; }
- /** set the main library directory */
+ /** set the main library directory */
// void setMainDir(const std::string & dir)
// { m_maindir = dir; }
- /** return the main directory */
- const std::string & mainDir() const
+ /** return the main directory */
+ const std::string & mainDir() const
{ return m_maindir; }
- /** get the path to the DB file */
- const std::string & dbName() const
+ /** get the path to the DB file */
+ const std::string & dbName() const
{ return m_dbname; }
- void notify(NotifyType t, const boost::any & param);
+ void notify(NotifyType t, const boost::any & param);
- /** add a file to the library
- * @param folder the path of the containing folder
- * @param file the file path
- * @param manage pass true it the library *manage* the file. Currently unsupported.
- */
- library_id_t addFileAndFolder(const std::string & folder,
- const std::string & file, bool manage);
+ /** add a file to the library
+ * @param folder the path of the containing folder
+ * @param file the file path
+ * @param manage pass true it the library *manage* the file. Currently unsupported.
+ */
+ library_id_t addFileAndFolder(const std::string & folder,
+ const std::string & file, bool manage);
- /** add a fs file to the library
+ /** add a fs file to the library
* @param file the file path
* @return the id of the fs_file, -1 in case of error
*/
@@ -110,20 +110,21 @@ public:
*/
std::string getFsFile(library_id_t id);
- /** add a file to the library
- * @param folder_id the id of the containing folder
- * @param file the file path
- * @param manage pass true it the library *manage* the file. Currently unsupported.
- */
- library_id_t addFile(library_id_t folder_id, const std::string & file, bool manage);
-
- /** add a bundle of files to the library
- * @param folder_id the id of the containing folder
- * @param bundle the bundle
- * @param manage pass true it the library *manage* the file. Currently unsupported.
- */
- library_id_t addBundle(library_id_t folder_id, const eng::FileBundle::Ptr & bundle,
- bool manage);
+ /** add a file to the library
+ * @param folder_id the id of the containing folder
+ * @param file the file path
+ * @param manage pass true it the library *manage* the file. Currently unsupported.
+ */
+ library_id_t addFile(library_id_t folder_id, const std::string & file, bool manage);
+
+ /** add a bundle of files to the library
+ * @param folder_id the id of the containing folder
+ * @param bundle the bundle
+ * @param manage pass true it the library *manage* the file. Currently unsupported.
+ */
+ library_id_t addBundle(library_id_t folder_id,
+ const eng::FileBundle::Ptr & bundle,
+ bool manage);
/** add a sidecar fsfile to a bundle (file)
* @param file_id the id of the file bundle
* @param fsfile_id the id of the fsfile
@@ -136,39 +137,40 @@ public:
* @return true if success
*/
bool addJpegFileToBundle(library_id_t file_id, library_id_t fsfile_id);
-
- /** Get a specific folder id from the library
- * @param folder the folder path to check
- * @return the folder, NULL if not found
- */
- LibFolder::Ptr getFolder(const std::string & folder);
-
- /** Add a folder
- * @param folder the folder path
- */
- LibFolder::Ptr addFolder(const std::string & folder);
- /** List all the folders.
- * @param l the list of LibFolder
- */
- void getAllFolders(const LibFolder::ListPtr & l);
-
- /** List the folder content
- * @param folder_id id of the folder
- * @param fl the resulting file list
- */
- void getFolderContent(library_id_t folder_id, const LibFile::ListPtr & fl);
- int countFolder(library_id_t folder_id);
- void getAllKeywords(const Keyword::ListPtr & l);
- void getKeywordContent(library_id_t keyword_id, const LibFile::ListPtr & fl);
+
+ /** Get a specific folder id from the library
+ * @param folder the folder path to check
+ * @return the folder, NULL if not found
+ */
+ LibFolder::Ptr getFolder(const std::string & folder);
+
+ /** Add a folder
+ * @param folder the folder path
+ */
+ LibFolder::Ptr addFolder(const std::string & folder);
+ /** List all the folders.
+ * @param l the list of LibFolder
+ */
+ void getAllFolders(const LibFolder::ListPtr & l);
+
+ /** List the folder content
+ * @param folder_id id of the folder
+ * @param fl the resulting file list
+ */
+ void getFolderContent(library_id_t folder_id, const LibFile::ListPtr & fl);
+ int countFolder(library_id_t folder_id);
+ void getAllKeywords(const Keyword::ListPtr & l);
+ void getKeywordContent(library_id_t keyword_id, const LibFile::ListPtr & fl);
/** get the metadata block (XMP) */
- void getMetaData(library_id_t file_id, const LibMetadata::Ptr & );
+ void getMetaData(library_id_t file_id, const LibMetadata::Ptr & );
/** set the metadata block (XMP) */
bool setMetaData(library_id_t file_id, const LibMetadata::Ptr & );
- bool setMetaData(library_id_t file_id, fwk::PropertyIndex meta, const fwk::PropertyValue & value);
+ bool setMetaData(library_id_t file_id, fwk::PropertyIndex meta,
+ const fwk::PropertyValue & value);
bool moveFileToFolder(library_id_t file_id, library_id_t folder_id);
- void getAllLabels(const eng::Label::ListPtr & l);
+ void getAllLabels(const eng::Label::ListPtr & l);
library_id_t addLabel(const std::string & name, const std::string & colour);
library_id_t addLabel(const std::string & name, const fwk::RgbColour & c);
bool updateLabel(library_id_t label_id, const std::string & name, const std::string & colour);
@@ -177,26 +179,26 @@ public:
/** Trigger the processing of the XMP update queue */
bool processXmpUpdateQueue(bool rewrite_xmp);
- /** Locate the keyword, creating it if needed
- * @param keyword the keyword to locate
- * @return -1 if not found (shouldn't happen) or the id of the
- * keyword, either found or just created.
- */
- library_id_t makeKeyword(const std::string & keyword);
- /** Assign a keyword to a file.
- * @param kw_id the keyword id
- * @param file_id the file id
- * @return true if success, false if error
- */
- bool assignKeyword(library_id_t kw_id, library_id_t file_id);
-
- int checkDatabaseVersion();
-
- db::IConnectionDriver::Ptr dbDriver()
+ /** Locate the keyword, creating it if needed
+ * @param keyword the keyword to locate
+ * @return -1 if not found (shouldn't happen) or the id of the
+ * keyword, either found or just created.
+ */
+ library_id_t makeKeyword(const std::string & keyword);
+ /** Assign a keyword to a file.
+ * @param kw_id the keyword id
+ * @param file_id the file id
+ * @return true if success, false if error
+ */
+ bool assignKeyword(library_id_t kw_id, library_id_t file_id);
+
+ int checkDatabaseVersion();
+
+ db::IConnectionDriver::Ptr dbDriver()
{ return m_dbdrv; }
private:
- bool init();
- bool _initDb();
+ bool init();
+ bool _initDb();
/** external sqlite fucntion to trigger the rewrite of the XMP */
void triggerRewriteXmp(void);
@@ -212,17 +214,17 @@ private:
std::string m_maindir;
std::string m_dbname;
- db::IConnectionManagerDriver::Ptr m_dbmgr;
- db::IConnectionDriver::Ptr m_dbdrv;
- std::tr1::weak_ptr<fwk::NotificationCenter> m_notif_center;
- bool m_inited;
+ db::IConnectionManagerDriver::Ptr m_dbmgr;
+ db::IConnectionDriver::Ptr m_dbdrv;
+ std::tr1::weak_ptr<fwk::NotificationCenter> m_notif_center;
+ bool m_inited;
};
-
+
struct LibNotification
{
- Library::NotifyType type;
- boost::any param;
+ Library::NotifyType type;
+ boost::any param;
};
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]