mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-08-10 14:09:48 +00:00
Fix namespaces.
Build works, except for incredis which I'm going to move out anyways.
This commit is contained in:
parent
a5477c99cf
commit
7a3438def6
24 changed files with 79 additions and 78 deletions
|
@ -131,7 +131,6 @@ add_subdirectory(lib/pbl)
|
|||
add_subdirectory(lib/glob2regex)
|
||||
add_subdirectory(src/backends)
|
||||
add_subdirectory(src/core)
|
||||
add_subdirectory(src/incredis)
|
||||
add_shared_git_project(lib/duckhandy)
|
||||
|
||||
#Actions
|
||||
|
@ -154,6 +153,8 @@ target_link_libraries(${PROJECT_NAME}
|
|||
INTERFACE ${Boost_LIBRARIES}
|
||||
INTERFACE ${bare_name}-pq
|
||||
INTERFACE ${bare_name}-inc
|
||||
)
|
||||
target_link_libraries(${bare_name}-inc
|
||||
INTERFACE duckhandy
|
||||
)
|
||||
|
||||
|
|
|
@ -82,8 +82,8 @@ namespace dindb {
|
|||
virtual std::vector<LocatedSet> locate_sets_in_db ( const std::string& parSearch, const std::vector<GroupIDType>& parSets, bool parCaseInsensitive ) = 0;
|
||||
|
||||
virtual std::vector<GroupIDType> find_all_sets ( void ) = 0;
|
||||
virtual std::vector<dinhelp::MaxSizedArray<std::string, 4>> find_set_details ( const std::vector<GroupIDType>& parSets ) = 0;
|
||||
virtual std::vector<dinhelp::MaxSizedArray<std::string, 1>> find_file_details ( GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir ) = 0;
|
||||
virtual std::vector<dhandy::MaxSizedArray<std::string, 4>> find_set_details ( const std::vector<GroupIDType>& parSets ) = 0;
|
||||
virtual std::vector<dhandy::MaxSizedArray<std::string, 1>> find_file_details ( GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir ) = 0;
|
||||
virtual std::vector<std::string> find_paths_starting_by ( GroupIDType parGroupID, uint16_t parLevel, boost::string_ref parPath ) = 0;
|
||||
};
|
||||
} //namespace dindb
|
||||
|
|
|
@ -30,7 +30,7 @@ struct pg_param;
|
|||
typedef pg_param PGparam;
|
||||
|
||||
namespace pq {
|
||||
namespace bt = dinhelp::bt;
|
||||
namespace bt = dhandy::bt;
|
||||
|
||||
class Connection;
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ namespace dindb {
|
|||
return dindb::find_all_sets(*m_conn);
|
||||
}
|
||||
|
||||
std::vector<dinhelp::MaxSizedArray<std::string, 4>> BackendPostgreSql::find_set_details (const std::vector<GroupIDType>& parSets) {
|
||||
std::vector<dhandy::MaxSizedArray<std::string, 4>> BackendPostgreSql::find_set_details (const std::vector<GroupIDType>& parSets) {
|
||||
return dindb::find_set_details<
|
||||
dindb::SetDetail_ID,
|
||||
dindb::SetDetail_Desc,
|
||||
|
@ -154,7 +154,7 @@ namespace dindb {
|
|||
>(*m_conn, parSets);
|
||||
}
|
||||
|
||||
std::vector<dinhelp::MaxSizedArray<std::string, 1>> BackendPostgreSql::find_file_details (GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir) {
|
||||
std::vector<dhandy::MaxSizedArray<std::string, 1>> BackendPostgreSql::find_file_details (GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir) {
|
||||
return dindb::find_file_details<dindb::FileDetail_Path>(*m_conn, parSetID, parLevel, parDir);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ namespace dindb {
|
|||
virtual std::vector<LocatedSet> locate_sets_in_db ( const std::string& parSearch, const std::vector<GroupIDType>& parSets, bool parCaseInsensitive ) override;
|
||||
|
||||
virtual std::vector<GroupIDType> find_all_sets ( void ) override;
|
||||
virtual std::vector<dinhelp::MaxSizedArray<std::string, 4>> find_set_details ( const std::vector<GroupIDType>& parSets ) override;
|
||||
virtual std::vector<dinhelp::MaxSizedArray<std::string, 1>> find_file_details ( GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir ) override;
|
||||
virtual std::vector<dhandy::MaxSizedArray<std::string, 4>> find_set_details ( const std::vector<GroupIDType>& parSets ) override;
|
||||
virtual std::vector<dhandy::MaxSizedArray<std::string, 1>> find_file_details ( GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir ) override;
|
||||
virtual std::vector<std::string> find_paths_starting_by ( GroupIDType parGroupID, uint16_t parLevel, boost::string_ref parPath ) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
namespace dinhelp {
|
||||
namespace dhandy {
|
||||
template <typename OuterList, typename InnerList=typename OuterList::value_type, typename InnerVal=typename InnerList::value_type>
|
||||
class FlatInsertIn2DList {
|
||||
public:
|
||||
|
@ -52,7 +52,7 @@ namespace dinhelp {
|
|||
const std::size_t m_inner_count;
|
||||
const std::size_t m_outer_count;
|
||||
};
|
||||
} //namespace dinhelp
|
||||
} //namespace dhandy
|
||||
|
||||
#include "flatinsertin2dlist.inl"
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace dinhelp {
|
||||
namespace dhandy {
|
||||
template <typename OuterList, typename InnerList, typename InnerVal>
|
||||
FlatInsertIn2DList<OuterList, InnerList, InnerVal>::FlatInsertIn2DList (list_type* parList, std::size_t parInnerCount, std::size_t parOuterCount) :
|
||||
m_list(parList),
|
||||
|
@ -70,4 +70,4 @@ namespace dinhelp {
|
|||
return (m_list->size() - 1) * m_inner_count + m_list[m_list->size() - 1].size();
|
||||
}
|
||||
}
|
||||
} //namespace dinhelp
|
||||
} //namespace dhandy
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace pq {
|
|||
} //namespace pq
|
||||
|
||||
namespace dindb {
|
||||
using dinhelp::MaxSizedArray;
|
||||
using dhandy::MaxSizedArray;
|
||||
|
||||
enum SetDetails {
|
||||
SetDetail_Desc = 0x01,
|
||||
|
@ -109,7 +109,7 @@ namespace dindb {
|
|||
template <SetDetails... D>
|
||||
inline
|
||||
auto find_set_details (pq::Connection& parDB, const std::vector<GroupIDType>& parIDs) -> std::vector<MaxSizedArray<std::string, sizeof...(D)>> {
|
||||
using dinhelp::FlatInsertIn2DList;
|
||||
using dhandy::FlatInsertIn2DList;
|
||||
typedef std::vector<MaxSizedArray<std::string, sizeof...(D)>> ReturnType;
|
||||
typedef void(FlatInsertIn2DList<ReturnType>::*FlatPushBackFunc)(std::string&&);
|
||||
|
||||
|
@ -125,7 +125,7 @@ namespace dindb {
|
|||
template <FileDetails... D>
|
||||
inline
|
||||
auto find_file_details (pq::Connection& parDB, GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir) -> std::vector<MaxSizedArray<std::string, sizeof...(D)>> {
|
||||
using dinhelp::FlatInsertIn2DList;
|
||||
using dhandy::FlatInsertIn2DList;
|
||||
typedef std::vector<MaxSizedArray<std::string, sizeof...(D)>> ReturnType;
|
||||
typedef void(FlatInsertIn2DList<ReturnType>::*FlatPushBackFunc)(std::string&&);
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ namespace dindb {
|
|||
}
|
||||
|
||||
void BackendRedis::connect() {
|
||||
using dinhelp::lexical_cast;
|
||||
using dhandy::lexical_cast;
|
||||
|
||||
m_redis.connect();
|
||||
m_redis.wait_for_connect();
|
||||
|
@ -159,7 +159,7 @@ namespace dindb {
|
|||
}
|
||||
|
||||
void BackendRedis::write_files (const std::vector<mchlib::FileRecordData>& parData, const mchlib::SetRecordDataFull& parSetData, const std::string& parSignature) {
|
||||
using dinhelp::lexical_cast;
|
||||
using dhandy::lexical_cast;
|
||||
using boost::string_ref;
|
||||
|
||||
const auto data_size = static_cast<int>(parData.size());
|
||||
|
@ -275,11 +275,11 @@ namespace dindb {
|
|||
return dindb::find_all_sets(m_redis);
|
||||
}
|
||||
|
||||
std::vector<dinhelp::MaxSizedArray<std::string, 4>> BackendRedis::find_set_details (const std::vector<GroupIDType>& parSets) {
|
||||
std::vector<dhandy::MaxSizedArray<std::string, 4>> BackendRedis::find_set_details (const std::vector<GroupIDType>& parSets) {
|
||||
return dindb::find_set_details(m_redis, parSets);
|
||||
}
|
||||
|
||||
std::vector<dinhelp::MaxSizedArray<std::string, 1>> BackendRedis::find_file_details (GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir) {
|
||||
std::vector<dhandy::MaxSizedArray<std::string, 1>> BackendRedis::find_file_details (GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir) {
|
||||
return dindb::find_file_details(m_redis, parSetID, parLevel, parDir);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ namespace dindb {
|
|||
virtual std::vector<LocatedSet> locate_sets_in_db ( const std::string& parSubstr, const std::vector<GroupIDType>& parSets, bool parCaseInsensitive ) override;
|
||||
|
||||
virtual std::vector<GroupIDType> find_all_sets ( void ) override;
|
||||
virtual std::vector<dinhelp::MaxSizedArray<std::string, 4>> find_set_details ( const std::vector<GroupIDType>& parSets ) override;
|
||||
virtual std::vector<dinhelp::MaxSizedArray<std::string, 1>> find_file_details ( GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir ) override;
|
||||
virtual std::vector<dhandy::MaxSizedArray<std::string, 4>> find_set_details ( const std::vector<GroupIDType>& parSets ) override;
|
||||
virtual std::vector<dhandy::MaxSizedArray<std::string, 1>> find_file_details ( GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir ) override;
|
||||
virtual std::vector<std::string> find_paths_starting_by ( GroupIDType parGroupID, uint16_t parLevel, boost::string_ref parPath ) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
namespace dindb {
|
||||
namespace {
|
||||
std::pair<bool, std::size_t> confirm_dele (redis::IncRedisBatch& parBatch, const std::vector<GroupIDType>& parIDs, ConfirmDeleCallback parConf) {
|
||||
using dinhelp::lexical_cast;
|
||||
using dhandy::lexical_cast;
|
||||
|
||||
if (parIDs.empty())
|
||||
return std::make_pair(false, parIDs.size());
|
||||
|
@ -60,7 +60,7 @@ namespace dindb {
|
|||
}
|
||||
|
||||
template <typename IT, IT CHUNK, typename F, IT... SVALS>
|
||||
void chunked_run_pvt (redis::Batch& parBatch, const char* parCommand, IT parFrom, IT parCount, F parMakeKey, dinhelp::bt::number_seq<IT, SVALS...>) {
|
||||
void chunked_run_pvt (redis::Batch& parBatch, const char* parCommand, IT parFrom, IT parCount, F parMakeKey, dhandy::bt::number_seq<IT, SVALS...>) {
|
||||
for (IT i = 0; i < parCount / CHUNK; ++i) {
|
||||
parBatch.run(parCommand, parMakeKey(i * CHUNK + parFrom + SVALS)...);
|
||||
}
|
||||
|
@ -72,12 +72,12 @@ namespace dindb {
|
|||
|
||||
template <typename IT, IT CHUNK, typename F>
|
||||
void chunked_run (redis::Batch& parBatch, const char* parCommand, IT parFrom, IT parCount, F parMakeKey) {
|
||||
chunked_run_pvt<IT, CHUNK, F>(parBatch, parCommand, parFrom, parCount, parMakeKey, dinhelp::bt::number_range<IT, 0, CHUNK>());
|
||||
chunked_run_pvt<IT, CHUNK, F>(parBatch, parCommand, parFrom, parCount, parMakeKey, dhandy::bt::number_range<IT, 0, CHUNK>());
|
||||
};
|
||||
} //unnamed namespace
|
||||
|
||||
void delete_group_from_db (redis::IncRedis& parRedis, redis::Script& parDeleTagIfInSet, redis::Script& parDeleHash, const std::vector<GroupIDType>& parIDs, ConfirmDeleCallback parConf) {
|
||||
using dinhelp::lexical_cast;
|
||||
using dhandy::lexical_cast;
|
||||
using IDRange = std::tuple<GroupIDType, FileIDType, FileIDType>;
|
||||
|
||||
auto set_batch = parRedis.make_batch();
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace dindb {
|
|||
using boost::make_tuple;
|
||||
using redis::Reply;
|
||||
using std::vector;
|
||||
using dinhelp::lexical_cast;
|
||||
using dhandy::lexical_cast;
|
||||
|
||||
assert(parReplies.size() == parIDs.size());
|
||||
return boost::copy_range<vector<T>>(
|
||||
|
@ -113,7 +113,7 @@ namespace dindb {
|
|||
|
||||
template <>
|
||||
LocatedItem construct (const std::vector<redis::Reply>& parData, const std::string& parID) {
|
||||
using dinhelp::lexical_cast;
|
||||
using dhandy::lexical_cast;
|
||||
|
||||
//parData is expected to contain: "path", "group_id", "tags"
|
||||
|
||||
|
@ -127,7 +127,7 @@ namespace dindb {
|
|||
|
||||
template <>
|
||||
LocatedSet construct (const std::vector<redis::Reply>& parData, const std::string& parID) {
|
||||
using dinhelp::lexical_cast;
|
||||
using dhandy::lexical_cast;
|
||||
|
||||
//parData is expected to contain: "desc", "item_count", "dir_count"
|
||||
|
||||
|
@ -178,7 +178,7 @@ namespace dindb {
|
|||
|
||||
std::vector<GroupIDType> retval;
|
||||
for (const auto& itm : parRedis.scan(PROGRAM_NAME ":set:*")) {
|
||||
retval.push_back(dinhelp::lexical_cast<GroupIDType>(split_and_trim(itm, ':').back()));
|
||||
retval.push_back(dhandy::lexical_cast<GroupIDType>(split_and_trim(itm, ':').back()));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ namespace dindb {
|
|||
}
|
||||
|
||||
std::vector<LocatedSet> locate_sets_in_db (redis::IncRedis& parRedis, const std::string& parSubstr, const std::vector<GroupIDType>& parSets, bool parCaseInsensitive) {
|
||||
using dinhelp::lexical_cast;
|
||||
using dhandy::lexical_cast;
|
||||
|
||||
auto filter_case_ins = [&parSubstr, &parSets](const boost::tuple<std::vector<redis::Reply>, std::string>& t) {
|
||||
const auto& s = redis::get_string(t.get<0>()[0]);
|
||||
|
@ -260,8 +260,8 @@ namespace dindb {
|
|||
return locate_in_bursts<LocatedSet>(parRedis, PROGRAM_NAME ":set:*", filter, "desc", "item_count", "dir_count");
|
||||
}
|
||||
|
||||
std::vector<dinhelp::MaxSizedArray<std::string, 4>> find_set_details (redis::IncRedis& parRedis, const std::vector<GroupIDType>& parSets) {
|
||||
using dinhelp::lexical_cast;
|
||||
std::vector<dhandy::MaxSizedArray<std::string, 4>> find_set_details (redis::IncRedis& parRedis, const std::vector<GroupIDType>& parSets) {
|
||||
using dhandy::lexical_cast;
|
||||
|
||||
auto batch = parRedis.make_batch();
|
||||
for (auto set_id : parSets) {
|
||||
|
@ -270,7 +270,7 @@ namespace dindb {
|
|||
}
|
||||
batch.throw_if_failed();
|
||||
|
||||
std::vector<dinhelp::MaxSizedArray<std::string, 4>> retval;
|
||||
std::vector<dhandy::MaxSizedArray<std::string, 4>> retval;
|
||||
auto curr_set = parSets.begin();
|
||||
for (const auto& reply : batch.replies()) {
|
||||
const auto& reply_list = get_array(reply);
|
||||
|
@ -289,9 +289,9 @@ namespace dindb {
|
|||
return retval;
|
||||
};
|
||||
|
||||
std::vector<dinhelp::MaxSizedArray<std::string, 1>> find_file_details (redis::IncRedis& parRedis, GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir) {
|
||||
using dinhelp::lexical_cast;
|
||||
using RetListType = std::vector<dinhelp::MaxSizedArray<std::string, 1>>;
|
||||
std::vector<dhandy::MaxSizedArray<std::string, 1>> find_file_details (redis::IncRedis& parRedis, GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir) {
|
||||
using dhandy::lexical_cast;
|
||||
using RetListType = std::vector<dhandy::MaxSizedArray<std::string, 1>>;
|
||||
|
||||
const double level = static_cast<float>(parLevel);
|
||||
auto lst = parRedis.zrangebyscore(PROGRAM_NAME ":levels:" + lexical_cast<std::string>(parSetID), level, true, level, true, false);
|
||||
|
@ -305,7 +305,7 @@ namespace dindb {
|
|||
}
|
||||
batch.throw_if_failed();
|
||||
|
||||
std::vector<dinhelp::MaxSizedArray<std::string, 1>> retval;
|
||||
std::vector<dhandy::MaxSizedArray<std::string, 1>> retval;
|
||||
for (auto& reply : batch.replies()) {
|
||||
if (redis::RedisVariantType_Nil != reply.which()) {
|
||||
auto curr_path = get_string(reply);
|
||||
|
@ -320,7 +320,7 @@ namespace dindb {
|
|||
|
||||
std::vector<std::string> find_paths_starting_by (redis::IncRedis& parRedis, GroupIDType parGroupID, uint16_t parLevel, boost::string_ref parPath) {
|
||||
using boost::adaptors::transformed;
|
||||
using dinhelp::MaxSizedArray;
|
||||
using dhandy::MaxSizedArray;
|
||||
|
||||
auto file_details = find_file_details(parRedis, parGroupID, parLevel, parPath);
|
||||
return boost::copy_range<std::vector<std::string>>(
|
||||
|
|
|
@ -35,8 +35,8 @@ namespace dindb {
|
|||
std::vector<LocatedItem> locate_in_db ( redis::IncRedis& parRedis, const mchlib::TigerHash& parSearch, const TagList& parTags );
|
||||
std::vector<LocatedSet> locate_sets_in_db ( redis::IncRedis& parRedis, const std::string& parSubstr, bool parCaseInsensitive );
|
||||
std::vector<LocatedSet> locate_sets_in_db ( redis::IncRedis& parRedis, const std::string& parSubstr, const std::vector<GroupIDType>& parSets, bool parCaseInsensitive );
|
||||
std::vector<dinhelp::MaxSizedArray<std::string, 4>> find_set_details ( redis::IncRedis& parRedis, const std::vector<GroupIDType>& parSets );
|
||||
std::vector<dinhelp::MaxSizedArray<std::string, 1>> find_file_details ( redis::IncRedis& parRedis, GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir );
|
||||
std::vector<dhandy::MaxSizedArray<std::string, 4>> find_set_details ( redis::IncRedis& parRedis, const std::vector<GroupIDType>& parSets );
|
||||
std::vector<dhandy::MaxSizedArray<std::string, 1>> find_file_details ( redis::IncRedis& parRedis, GroupIDType parSetID, uint16_t parLevel, boost::string_ref parDir );
|
||||
std::vector<std::string> find_paths_starting_by ( redis::IncRedis& parRedis, GroupIDType parGroupID, uint16_t parLevel, boost::string_ref parPath );
|
||||
} //namespace dindb
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace redis {
|
|||
struct StructAdapt<dindb::FileRecordDataWithGroup> {
|
||||
template <typename R>
|
||||
static bool decode (const R& parRange, dindb::FileRecordDataWithGroup& parOut) {
|
||||
using dinhelp::lexical_cast;
|
||||
using dhandy::lexical_cast;
|
||||
|
||||
std::array<std::string, 2> mime;
|
||||
std::string group_key;
|
||||
|
@ -75,7 +75,7 @@ namespace redis {
|
|||
struct StructAdapt<mchlib::SetRecordDataFull> {
|
||||
template <typename R>
|
||||
static bool decode (const R& parRange, mchlib::SetRecordDataFull& parOut) {
|
||||
using dinhelp::lexical_cast;
|
||||
using dhandy::lexical_cast;
|
||||
|
||||
for (const auto& itm : parRange) {
|
||||
if (itm.first == "name")
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace std {
|
|||
namespace dindb {
|
||||
namespace {
|
||||
std::string make_file_key (FileIDType parID) {
|
||||
return PROGRAM_NAME ":file:" + dinhelp::lexical_cast<std::string>(parID);
|
||||
return PROGRAM_NAME ":file:" + dhandy::lexical_cast<std::string>(parID);
|
||||
}
|
||||
|
||||
std::vector<boost::regex> compile_regexes (const std::vector<std::string>& parRegexes) {
|
||||
|
@ -55,7 +55,7 @@ namespace dindb {
|
|||
}
|
||||
|
||||
void run_id_based_script (redis::IncRedis& parRedis, redis::Script& parScript, const std::vector<FileIDType>& parFiles, const std::vector<boost::string_ref>& parTags, GroupIDType parSet) {
|
||||
using dinhelp::lexical_cast;
|
||||
using dhandy::lexical_cast;
|
||||
|
||||
auto batch = parRedis.command().make_batch();
|
||||
const std::string set_id = lexical_cast<std::string>(parSet);
|
||||
|
@ -73,7 +73,7 @@ namespace dindb {
|
|||
}
|
||||
|
||||
void run_regex_based_script(redis::IncRedis& parRedis, redis::Script& parTagIfInSet, const std::vector<std::string>& parRegexes, const std::vector<boost::string_ref>& parTags, GroupIDType parSet) {
|
||||
using dinhelp::lexical_cast;
|
||||
using dhandy::lexical_cast;
|
||||
|
||||
const std::string set_id = lexical_cast<std::string>(parSet);
|
||||
const auto regexes = compile_regexes(parRegexes);
|
||||
|
@ -101,7 +101,7 @@ namespace dindb {
|
|||
template <typename T>
|
||||
T id_from_redis_key (const std::string& parKey) {
|
||||
assert(not parKey.empty());
|
||||
return dinhelp::lexical_cast<T>(dincore::split_and_trim(parKey, ':').back());
|
||||
return dhandy::lexical_cast<T>(dincore::split_and_trim(parKey, ':').back());
|
||||
}
|
||||
} //unnamed namespace
|
||||
|
||||
|
@ -142,7 +142,7 @@ namespace dindb {
|
|||
}
|
||||
|
||||
void delete_all_tags (redis::IncRedis& parRedis, redis::Script& parDeleIfInSet, const std::vector<std::string>& parRegexes, GroupIDType parSet) {
|
||||
using dinhelp::lexical_cast;
|
||||
using dhandy::lexical_cast;
|
||||
|
||||
const auto regexes = compile_regexes(parRegexes);
|
||||
|
||||
|
|
|
@ -102,13 +102,13 @@ namespace redis {
|
|||
}
|
||||
|
||||
int IncRedis::hincrby (boost::string_ref parKey, boost::string_ref parField, int parInc) {
|
||||
const auto inc = dinhelp::lexical_cast<std::string>(parInc);
|
||||
const auto inc = dhandy::lexical_cast<std::string>(parInc);
|
||||
auto reply = m_command.run("HINCRBY", parKey, parField, inc);
|
||||
return get_integer(reply);
|
||||
}
|
||||
|
||||
auto IncRedis::srandmember (boost::string_ref parKey, int parCount) -> opt_string_list {
|
||||
return optional_string_list(m_command.run("SRANDMEMBER", parKey, dinhelp::lexical_cast<std::string>(parCount)));
|
||||
return optional_string_list(m_command.run("SRANDMEMBER", parKey, dhandy::lexical_cast<std::string>(parCount)));
|
||||
}
|
||||
|
||||
auto IncRedis::srandmember (boost::string_ref parKey) -> opt_string {
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace redis {
|
|||
}
|
||||
|
||||
IncRedisBatch& IncRedisBatch::select (int parIndex) {
|
||||
m_batch.run("SELECT", dinhelp::lexical_cast<std::string>(parIndex));
|
||||
m_batch.run("SELECT", dhandy::lexical_cast<std::string>(parIndex));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -60,12 +60,12 @@ namespace redis {
|
|||
}
|
||||
|
||||
IncRedisBatch& IncRedisBatch::hincrby (boost::string_ref parKey, boost::string_ref parField, int parInc) {
|
||||
m_batch.run("HINCRBY", parKey, parField, dinhelp::lexical_cast<std::string>(parInc));
|
||||
m_batch.run("HINCRBY", parKey, parField, dhandy::lexical_cast<std::string>(parInc));
|
||||
return *this;
|
||||
}
|
||||
|
||||
IncRedisBatch& IncRedisBatch::srandmember (boost::string_ref parKey, int parCount) {
|
||||
m_batch.run("SRANDMEMBER", parKey, dinhelp::lexical_cast<std::string>(parCount));
|
||||
m_batch.run("SRANDMEMBER", parKey, dhandy::lexical_cast<std::string>(parCount));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace redis {
|
|||
|
||||
namespace implem {
|
||||
template <std::size_t... I, typename... Args>
|
||||
void run_conv_floats_to_strings ( Batch& parBatch, dinhelp::bt::index_seq<I...>, Args&&... parArgs );
|
||||
void run_conv_floats_to_strings ( Batch& parBatch, dhandy::bt::index_seq<I...>, Args&&... parArgs );
|
||||
} //namespace implem
|
||||
|
||||
template <typename... Args>
|
||||
|
@ -115,7 +115,7 @@ namespace redis {
|
|||
static_assert(sizeof...(Args) >= 1, "No score/value pairs specified");
|
||||
static_assert(sizeof...(Args) % 2 == 0, "Uneven number of parameters received");
|
||||
|
||||
using dinhelp::bt::index_range;
|
||||
using dhandy::bt::index_range;
|
||||
|
||||
if (parChange) {
|
||||
if (ZADD_None == parMode)
|
||||
|
@ -155,17 +155,17 @@ namespace redis {
|
|||
}
|
||||
|
||||
template <std::size_t PreArgsCount, std::size_t... I, typename... Args>
|
||||
void run_conv_floats_to_strings_impl (Batch& parBatch, dinhelp::bt::index_seq<I...>, Args&&... parArgs) {
|
||||
void run_conv_floats_to_strings_impl (Batch& parBatch, dhandy::bt::index_seq<I...>, Args&&... parArgs) {
|
||||
static_assert(sizeof...(I) == sizeof...(Args), "Wrong number of indices");
|
||||
static_assert(PreArgsCount <= sizeof...(I), "Can't ignore more arguments than those that were received");
|
||||
parBatch.run(stringize_or_forward<PreArgsCount, I>(std::forward<Args>(parArgs))...);
|
||||
}
|
||||
|
||||
template <std::size_t... I, typename... Args>
|
||||
void run_conv_floats_to_strings (Batch& parBatch, dinhelp::bt::index_seq<I...>, Args&&... parArgs) {
|
||||
void run_conv_floats_to_strings (Batch& parBatch, dhandy::bt::index_seq<I...>, Args&&... parArgs) {
|
||||
static_assert(sizeof...(Args) >= sizeof...(I), "Unexpected count, there should be at least as many argument as there are indices");
|
||||
constexpr const auto pre_args_count = sizeof...(Args) - sizeof...(I);
|
||||
run_conv_floats_to_strings_impl<pre_args_count>(parBatch, dinhelp::bt::index_range<0, sizeof...(Args)>(), std::forward<Args>(parArgs)...);
|
||||
run_conv_floats_to_strings_impl<pre_args_count>(parBatch, dhandy::bt::index_range<0, sizeof...(Args)>(), std::forward<Args>(parArgs)...);
|
||||
};
|
||||
} //namespace implem
|
||||
} //namespace redis
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace redis {
|
|||
}
|
||||
|
||||
long long get_integer_autoconv_if_str (const Reply &parReply) {
|
||||
using dinhelp::lexical_cast;
|
||||
using dhandy::lexical_cast;
|
||||
|
||||
const auto type = parReply.which();
|
||||
switch (type) {
|
||||
|
|
|
@ -42,8 +42,8 @@ namespace redis {
|
|||
}
|
||||
|
||||
Reply ScanIteratorBaseClass::run (const char* parCommand, long long parScanContext, std::size_t parCount) {
|
||||
const auto scan_context = dinhelp::lexical_cast<std::string>(parScanContext);
|
||||
const auto count_hint = dinhelp::lexical_cast<std::string>(parCount);
|
||||
const auto scan_context = dhandy::lexical_cast<std::string>(parScanContext);
|
||||
const auto count_hint = dhandy::lexical_cast<std::string>(parCount);
|
||||
if (m_match_pattern.empty())
|
||||
return m_command->run(parCommand, scan_context, "COUNT", count_hint);
|
||||
else
|
||||
|
@ -51,8 +51,8 @@ namespace redis {
|
|||
}
|
||||
|
||||
Reply ScanIteratorBaseClass::run (const char* parCommand, const boost::string_ref& parParameter, long long parScanContext, std::size_t parCount) {
|
||||
const auto scan_context = dinhelp::lexical_cast<std::string>(parScanContext);
|
||||
const auto count_hint = dinhelp::lexical_cast<std::string>(parCount);
|
||||
const auto scan_context = dhandy::lexical_cast<std::string>(parScanContext);
|
||||
const auto count_hint = dhandy::lexical_cast<std::string>(parCount);
|
||||
if (m_match_pattern.empty())
|
||||
return m_command->run(parCommand, parParameter, scan_context, "COUNT", count_hint);
|
||||
else
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace redis {
|
|||
|
||||
private:
|
||||
template <typename... Keys, typename... Values, std::size_t... KeyIndices, std::size_t... ValueIndices>
|
||||
void run_with_indices ( Batch& parBatch, const std::tuple<Keys...>& parKeys, const std::tuple<Values...>& parValues, dinhelp::bt::index_seq<KeyIndices...>, dinhelp::bt::index_seq<ValueIndices...> );
|
||||
void run_with_indices ( Batch& parBatch, const std::tuple<Keys...>& parKeys, const std::tuple<Values...>& parValues, dhandy::bt::index_seq<KeyIndices...>, dhandy::bt::index_seq<ValueIndices...> );
|
||||
|
||||
boost::string_ref m_sha1;
|
||||
ScriptManager* m_manager;
|
||||
|
@ -55,13 +55,13 @@ namespace redis {
|
|||
parBatch,
|
||||
parKeys,
|
||||
parValues,
|
||||
::dinhelp::bt::index_range<0, sizeof...(Keys)>(),
|
||||
::dinhelp::bt::index_range<0, sizeof...(Values)>()
|
||||
::dhandy::bt::index_range<0, sizeof...(Keys)>(),
|
||||
::dhandy::bt::index_range<0, sizeof...(Values)>()
|
||||
);
|
||||
}
|
||||
|
||||
template <typename... Keys, typename... Values, std::size_t... KeyIndices, std::size_t... ValueIndices>
|
||||
void Script::run_with_indices (Batch& parBatch, const std::tuple<Keys...>& parKeys, const std::tuple<Values...>& parValues, dinhelp::bt::index_seq<KeyIndices...>, dinhelp::bt::index_seq<ValueIndices...>) {
|
||||
void Script::run_with_indices (Batch& parBatch, const std::tuple<Keys...>& parKeys, const std::tuple<Values...>& parValues, dhandy::bt::index_seq<KeyIndices...>, dhandy::bt::index_seq<ValueIndices...>) {
|
||||
static_assert(sizeof...(Keys) == sizeof...(KeyIndices), "Wrong index count");
|
||||
static_assert(sizeof...(Values) == sizeof...(ValueIndices), "Wrong value count");
|
||||
static_assert(sizeof...(Keys) == std::tuple_size<std::tuple<Keys...>>::value, "Wrong key count");
|
||||
|
@ -73,7 +73,7 @@ namespace redis {
|
|||
parBatch.run(
|
||||
"EVALSHA",
|
||||
m_sha1,
|
||||
dinhelp::lexical_cast<std::string>(sizeof...(Keys)),
|
||||
dhandy::lexical_cast<std::string>(sizeof...(Keys)),
|
||||
std::get<KeyIndices>(parKeys)...,
|
||||
std::get<ValueIndices>(parValues)...
|
||||
);
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace redis {
|
|||
if (parScript.empty())
|
||||
return boost::string_ref();
|
||||
|
||||
using dinhelp::lexical_cast;
|
||||
using dhandy::lexical_cast;
|
||||
|
||||
static_assert(20 == CryptoPP::SHA1::DIGESTSIZE, "Unexpected SHA1 digest size");
|
||||
static_assert(sizeof(LuaScriptHash) >= CryptoPP::SHA1::DIGESTSIZE, "Wrong SHA1 struct size");
|
||||
|
@ -60,9 +60,9 @@ namespace redis {
|
|||
LuaScriptHash digest;
|
||||
CryptoPP::SHA1().CalculateDigest(digest.raw_bytes, reinterpret_cast<const uint8_t*>(parScript.data()), parScript.size());
|
||||
//TODO: change when lexical_cast will support arrays
|
||||
auto sha1_str_parta = lexical_cast<std::string, dinhelp::tags::hexl>(__builtin_bswap64(digest.part_a));
|
||||
auto sha1_str_partb = lexical_cast<std::string, dinhelp::tags::hexl>(__builtin_bswap64(digest.part_b));
|
||||
auto sha1_str_partc = lexical_cast<std::string, dinhelp::tags::hexl>(__builtin_bswap32(digest.part_c));
|
||||
auto sha1_str_parta = lexical_cast<std::string, dhandy::tags::hexl>(__builtin_bswap64(digest.part_a));
|
||||
auto sha1_str_partb = lexical_cast<std::string, dhandy::tags::hexl>(__builtin_bswap64(digest.part_b));
|
||||
auto sha1_str_partc = lexical_cast<std::string, dhandy::tags::hexl>(__builtin_bswap32(digest.part_c));
|
||||
const std::string sha1_str =
|
||||
std::string(sizeof(digest.part_a) * 2 - sha1_str_parta.size(), '0') + sha1_str_parta +
|
||||
std::string(sizeof(digest.part_b) * 2 - sha1_str_partb.size(), '0') + sha1_str_partb +
|
||||
|
|
|
@ -163,9 +163,9 @@ namespace mchlib {
|
|||
|
||||
TigerHash retval;
|
||||
const string_ref inp(parString);
|
||||
retval.part_a = swap_long(dinhelp::lexical_cast<TigerPartType, dinhelp::tags::hex>(inp.substr(0, sizeof(TigerPartType) * 2)));
|
||||
retval.part_b = swap_long(dinhelp::lexical_cast<TigerPartType, dinhelp::tags::hex>(inp.substr(sizeof(TigerPartType) * 2, sizeof(TigerPartType) * 2)));
|
||||
retval.part_c = swap_long(dinhelp::lexical_cast<TigerPartType, dinhelp::tags::hex>(inp.substr(sizeof(TigerPartType) * 4, sizeof(TigerPartType) * 2)));
|
||||
retval.part_a = swap_long(dhandy::lexical_cast<TigerPartType, dhandy::tags::hex>(inp.substr(0, sizeof(TigerPartType) * 2)));
|
||||
retval.part_b = swap_long(dhandy::lexical_cast<TigerPartType, dhandy::tags::hex>(inp.substr(sizeof(TigerPartType) * 2, sizeof(TigerPartType) * 2)));
|
||||
retval.part_c = swap_long(dhandy::lexical_cast<TigerPartType, dhandy::tags::hex>(inp.substr(sizeof(TigerPartType) * 4, sizeof(TigerPartType) * 2)));
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
#include <boost/utility/string_ref.hpp>
|
||||
|
||||
TEST(duckhandy, lexical_cast) {
|
||||
using dinhelp::lexical_cast;
|
||||
using dinhelp::tags::hex;
|
||||
using dinhelp::tags::dec;
|
||||
using dinhelp::tags::bin;
|
||||
using dhandy::lexical_cast;
|
||||
using dhandy::tags::hex;
|
||||
using dhandy::tags::dec;
|
||||
using dhandy::tags::bin;
|
||||
|
||||
{
|
||||
const uint8_t value = 0x34;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue