1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2025-02-16 11:35:49 +00:00

Change namespace in machinery to mchlib.

This commit is contained in:
King_DuckZ 2016-01-05 12:49:27 +00:00
parent 4e29200b47
commit f5356e0c29
18 changed files with 50 additions and 48 deletions

View file

@ -40,7 +40,7 @@ namespace dinlib {
struct Settings;
} //namespace dinlib
namespace din {
namespace mchlib {
struct FileRecordData;
class Indexer {
@ -72,6 +72,6 @@ namespace din {
std::unique_ptr<LocalData> m_local_data;
};
} //namespace din
} //namespace mchlib
#endif

View file

@ -22,7 +22,7 @@
#include <stdexcept>
#include "dindexer-common/mediatypes.hpp"
namespace din {
namespace mchlib {
#if defined(WITH_MEDIA_AUTODETECT)
dinlib::MediaTypes guess_media_type ( std::string&& parPath );
@ -38,6 +38,6 @@ namespace din {
CantAutodetectException ( const char* parWhat );
};
#endif
} //namespace din
} //namespace mchlib
#endif

View file

@ -26,7 +26,7 @@
#include <boost/flyweight.hpp>
#include <boost/flyweight/no_locking.hpp>
namespace din {
namespace mchlib {
struct FileRecordData {
struct MimeStringTagStruct { };
typedef boost::flyweights::tag<MimeStringTagStruct> MimeStringTag;
@ -81,6 +81,6 @@ namespace din {
const boost::string_ref name;
const char type;
};
} //namespace din
} //namespace mchlib
#endif

View file

@ -22,7 +22,7 @@
#include <string>
#include <vector>
namespace din {
namespace mchlib {
struct TigerHash {
TigerHash ( void ) = default;
@ -44,6 +44,6 @@ namespace din {
std::string tiger_to_string ( const TigerHash& parHash, bool parUpcase=false );
void tiger_data ( const std::string& parData, TigerHash& parHash );
void tiger_data ( const std::vector<char>& parData, TigerHash& parHash );
} //namespace din
} //namespace mchlib
#endif

View file

@ -36,7 +36,7 @@
#endif
#include <cstdint>
namespace din {
namespace mchlib {
namespace {
using MountpointsMap = std::map<std::string, std::string>;
@ -329,4 +329,4 @@ namespace din {
};
}
#endif
} //namespace din
} //namespace mchlib

View file

@ -20,7 +20,7 @@
#include <string>
namespace din {
namespace mchlib {
#if defined(WITH_MEDIA_AUTODETECT)
enum OpticalTypes {
OpticalType_DVD,
@ -58,6 +58,6 @@ namespace din {
std::string m_mountpoint;
std::string m_device;
};
} //namespace din
} //namespace mchlib
#endif

View file

@ -41,7 +41,7 @@
#endif
#include <boost/utility/string_ref.hpp>
namespace din {
namespace mchlib {
using HashType = decltype(FileRecordData::hash);
namespace {
@ -367,4 +367,4 @@ namespace din {
#endif
return m_local_data->paths;
}
} //namespace din
} //namespace mchlib

View file

@ -20,7 +20,7 @@
#include "discinfo.hpp"
#include <utility>
namespace din {
namespace mchlib {
#if defined(WITH_MEDIA_AUTODETECT)
UnknownMediaTypeException::UnknownMediaTypeException (const std::string& parWhat) :
std::runtime_error(parWhat)
@ -66,4 +66,4 @@ namespace din {
}
}
#endif
} //namespace din
} //namespace mchlib

View file

@ -16,7 +16,7 @@
#include <boost/phoenix/bind/bind_member_function.hpp>
#include <boost/phoenix/operator.hpp>
namespace din {
namespace mchlib {
using MagicCookie = std::unique_ptr<magic_set, void(*)(magic_t)>;
struct MimeType::LocalData {
@ -109,4 +109,4 @@ namespace din {
return retval;
}
}
} //namespace din
} //namespace mchlib

View file

@ -23,7 +23,7 @@
#include <utility>
#include <boost/utility/string_ref.hpp>
namespace din {
namespace mchlib {
using SplitMime = std::pair<boost::string_ref, boost::string_ref>;
class MimeType {
@ -41,6 +41,6 @@ namespace din {
};
SplitMime split_mime ( const std::string& parFull );
} //namespace din
} //namespace mchlib
#endif

View file

@ -21,7 +21,7 @@
#include <ciso646>
#include <iostream>
namespace din {
namespace mchlib {
const std::string PathName::m_empty_str("");
namespace {
@ -210,4 +210,4 @@ namespace din {
}
return true;
}
} //namespace din
} //namespace mchlib

View file

@ -25,7 +25,7 @@
#include <map>
#include <iostream>
namespace din {
namespace mchlib {
class PathName {
public:
PathName ( PathName&& ) = default;
@ -57,6 +57,6 @@ namespace din {
PathName make_relative_path ( const PathName& parBasePath, const PathName& parOtherPath );
std::ostream& operator<< ( std::ostream& parStream, const PathName& parPath );
} //namespace din
} //namespace mchlib
#endif

View file

@ -28,7 +28,7 @@
#include <functional>
#include <boost/iterator/transform_iterator.hpp>
namespace din {
namespace mchlib {
template <typename C, typename Str=std::basic_string<C>, typename StrRef=boost::basic_string_ref<C>>
class StringPool {
typedef std::pair<StrRef, const Str*> StringListPair;
@ -63,7 +63,7 @@ namespace din {
PoolType m_pool;
StringListType m_strings;
};
} //namespace din
} //namespace mchlib
#include "stringpool.inl"

View file

@ -15,7 +15,7 @@
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
*/
namespace din {
namespace mchlib {
namespace implem {
template <typename StrRef>
std::pair<StrRef, bool> clone_ifp (const StrRef& parClone, StrRef parSource) {
@ -137,4 +137,4 @@ namespace din {
}
return;
}
} //namespace din
} //namespace mchlib

View file

@ -34,7 +34,7 @@ extern "C" void tiger ( const char* parStr, uint64_t parLength, uint64_t parHash
# error "Not implemented without SSE2"
#endif
namespace din {
namespace mchlib {
namespace {
const uint32_t g_buff_size = 1024 * 8;
const char g_tiger_padding = 0x80; //0x01 for V1
@ -139,4 +139,4 @@ namespace din {
void tiger_data (const std::vector<char>& parData, TigerHash& parHash) {
tiger (parData.data(), parData.size(), parHash.data, g_tiger_padding);
}
} //namespace din
} //namespace mchlib

View file

@ -32,7 +32,7 @@ namespace din {
namespace {
} //unnamed namespace
bool read_from_db (FileRecordData& parItem, SetRecordDataFull& parSet, const dinlib::SettingsDB& parDB, const TigerHash& parHash) {
bool read_from_db (mchlib::FileRecordData& parItem, mchlib::SetRecordDataFull& parSet, const dinlib::SettingsDB& parDB, const mchlib::TigerHash& parHash) {
using boost::lexical_cast;
pq::Connection conn(std::string(parDB.username), std::string(parDB.password), std::string(parDB.dbname), std::string(parDB.address), parDB.port);
@ -79,7 +79,7 @@ namespace din {
return true;
}
void write_to_db (const dinlib::SettingsDB& parDB, const std::vector<FileRecordData>& parData, const SetRecordData& parSetData) {
void write_to_db (const dinlib::SettingsDB& parDB, const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordData& parSetData) {
using std::chrono::system_clock;
using boost::lexical_cast;

View file

@ -26,14 +26,16 @@ namespace dinlib {
struct SettingsDB;;
} //namespace dinlib
namespace din {
namespace mchlib {
struct FileRecordData;
struct SetRecordData;
struct SetRecordDataFull;
struct TigerHash;
} //namespace mchlib
void write_to_db ( const dinlib::SettingsDB& parDB, const std::vector<FileRecordData>& parData, const SetRecordData& parSetData );
bool read_from_db ( FileRecordData& parItem, SetRecordDataFull& parSet, const dinlib::SettingsDB& parDB, const TigerHash& parHash );
namespace din {
void write_to_db ( const dinlib::SettingsDB& parDB, const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordData& parSetData );
bool read_from_db ( mchlib::FileRecordData& parItem, mchlib::SetRecordDataFull& parSet, const dinlib::SettingsDB& parDB, const mchlib::TigerHash& parHash );
} //namespace din
#endif

View file

@ -39,8 +39,8 @@
#endif
namespace {
void run_hash_calculation ( din::Indexer& parIndexer, bool parShowProgress );
bool add_to_db ( const std::vector<din::FileRecordData>& parData, const std::string& parSetName, char parType, const dinlib::SettingsDB& parDBSettings, bool parForce=false );
void run_hash_calculation ( mchlib::Indexer& parIndexer, bool parShowProgress );
bool add_to_db ( const std::vector<mchlib::FileRecordData>& parData, const std::string& parSetName, char parType, const dinlib::SettingsDB& parDBSettings, bool parForce=false );
} //unnamed namespace
int main (int parArgc, char* parArgv[]) {
@ -79,7 +79,7 @@ int main (int parArgc, char* parArgv[]) {
if (0 == vm.count("type")) {
std::cout << "Analyzing disc... ";
try {
const auto guessed_type = din::guess_media_type(std::string(search_path));
const auto guessed_type = mchlib::guess_media_type(std::string(search_path));
set_type = guessed_type;
std::cout << "Setting type to " << set_type << " ("
<< dinlib::media_type_to_str(guessed_type) << ")\n";
@ -99,12 +99,12 @@ int main (int parArgc, char* parArgv[]) {
std::cout << "constructing...\n";
din::Indexer indexer;
mchlib::Indexer indexer;
indexer.ignore_read_errors(vm.count("ignore-errors") > 0);
fastf::FileSearcher searcher(search_path);
fastf::FileSearcher::ConstCharVecType ext, ignore;
searcher.SetFollowSymlinks(true);
searcher.SetCallback(fastf::FileSearcher::CallbackType(std::bind(&din::Indexer::add_path, &indexer, _1, _2)));
searcher.SetCallback(fastf::FileSearcher::CallbackType(std::bind(&mchlib::Indexer::add_path, &indexer, _1, _2)));
searcher.Search(ext, ignore);
if (verbose) {
std::cout << "Fetching items list...\n";
@ -127,7 +127,7 @@ int main (int parArgc, char* parArgv[]) {
}
namespace {
void run_hash_calculation (din::Indexer& parIndexer, bool parShowProgress) {
void run_hash_calculation (mchlib::Indexer& parIndexer, bool parShowProgress) {
if (parIndexer.empty()) {
return;
}
@ -149,7 +149,7 @@ namespace {
std::cout << "Processing";
std::cout.flush();
const auto total_items = parIndexer.total_items();
std::thread hash_thread(&din::Indexer::calculate_hash, &parIndexer);
std::thread hash_thread(&mchlib::Indexer::calculate_hash, &parIndexer);
std::mutex progress_print;
std::size_t clear_size = 0;
const auto digit_count = static_cast<std::size_t>(std::log10(static_cast<double>(total_items))) + 1;
@ -180,23 +180,23 @@ namespace {
#endif
}
bool add_to_db (const std::vector<din::FileRecordData>& parData, const std::string& parSetName, char parType, const dinlib::SettingsDB& parDBSettings, bool parForce) {
using din::FileRecordData;
using din::SetRecordDataFull;
using din::SetRecordData;
bool add_to_db (const std::vector<mchlib::FileRecordData>& parData, const std::string& parSetName, char parType, const dinlib::SettingsDB& parDBSettings, bool parForce) {
using mchlib::FileRecordData;
using mchlib::SetRecordDataFull;
using mchlib::SetRecordData;
if (not parForce) {
const auto& first_hash = parData.front().hash;
FileRecordData itm;
SetRecordDataFull set;
const bool already_in_db = read_from_db(itm, set, parDBSettings, first_hash);
const bool already_in_db = din::read_from_db(itm, set, parDBSettings, first_hash);
if (already_in_db) {
return false;
}
}
SetRecordData set_data {parSetName, parType};
write_to_db(parDBSettings, parData, set_data);
din::write_to_db(parDBSettings, parData, set_data);
return true;
}
} //unnamed namespace