diff --git a/blobstamper/stamp_dict.cpp b/blobstamper/stamp_dict.cpp index fa5a085..fcec9e0 100644 --- a/blobstamper/stamp_dict.cpp +++ b/blobstamper/stamp_dict.cpp @@ -22,19 +22,19 @@ #include "stamp_dict.h" int -StampDict::ChooseStampSize(DictBase & dict) +StampDict::ChooseStampSize(std::shared_ptr dict) { - if (dict.size()<= UCHAR_MAX+1) + if (dict->size() <= UCHAR_MAX+1) { stamp_max_value = UCHAR_MAX; return 1; } - if (dict.size()<= USHRT_MAX+1) + if (dict->size() <= USHRT_MAX+1) { stamp_max_value = USHRT_MAX; return 2; } - if (dict.size()<= UINT_MAX+1) + if (dict->size() <= UINT_MAX+1) { stamp_max_value = UINT_MAX; return 4; @@ -75,7 +75,7 @@ StampDict::ExtractStr(Blob &blob) printf("StampDict::ExtractStr: Something is really wrong\n"); // FIXME better to throw something here :-) exit(1); } - long long actual_index = ((double) index_oracle) / stamp_max_value * dict.size(); - if ( actual_index == dict.size()) actual_index--; /* If we hit the boundary step inside a bit*/ - return dict.get(actual_index); + long long actual_index = ((double) index_oracle) / stamp_max_value * dict->size(); + if ( actual_index == dict->size()) actual_index--; /* If we hit the boundary step inside a bit*/ + return dict->get(actual_index); } diff --git a/blobstamper/stamp_dict.h b/blobstamper/stamp_dict.h index 308050b..49408db 100644 --- a/blobstamper/stamp_dict.h +++ b/blobstamper/stamp_dict.h @@ -25,6 +25,7 @@ #include "stamp.h" #include "stamp_arithm.h" #include "dict.h" +#include class StampDict: public StampBaseStr { @@ -34,13 +35,13 @@ class StampDict: public StampBaseStr StampArithm stamp32; StampArithm stamp64; int stamp_size; - DictBase& dict; + std::shared_ptr dict; unsigned long long stamp_max_value; - int ChooseStampSize(DictBase & dict); + int ChooseStampSize(std::shared_ptr dict); public: - StampDict(DictBase & dict_arg) : dict{dict_arg}, stamp_size{ChooseStampSize(dict_arg)} {}; + StampDict(std::shared_ptr dict_arg) : dict(dict_arg), stamp_size(ChooseStampSize(dict_arg)) {}; std::string ExtractStr(Blob &blob) override; int minSize() override {return stamp_size;} int maxSize() override {return stamp_size;} diff --git a/examples/exampleZZ.cpp b/examples/exampleZZ.cpp index 382b561..28c8bf2 100644 --- a/examples/exampleZZ.cpp +++ b/examples/exampleZZ.cpp @@ -54,7 +54,7 @@ char data[] = StampArithm stampс; - DictLCAlphaSmall dict; + auto dict = std::make_shared(); StampDict stamp_dict(dict); StampLottery4Recursion stamp_lot({stampс, stamp_dict}); diff --git a/t/120-stamp_dict.cpp b/t/120-stamp_dict.cpp index 5e32040..670b64c 100644 --- a/t/120-stamp_dict.cpp +++ b/t/120-stamp_dict.cpp @@ -48,7 +48,7 @@ main() { TEST_START(4); { /* 1..4 */ - DictTest dict; + auto dict = std::make_shared(); StampDict stamp(dict); Blob blob((char *) sample, 4); std::string s;