Skip to content

Commit 41ebf72

Browse files
committed
Replace boost with olp::porting any_cast
Relates-To: NLAM-157 Signed-off-by: Khomenko Denys <[email protected]>
1 parent a6e85ca commit 41ebf72

File tree

11 files changed

+34
-34
lines changed

11 files changed

+34
-34
lines changed

olp-cpp-sdk-core/src/cache/InMemoryCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ bool InMemoryCache::Put(const std::string& key, const boost::any& item,
6565
return ret.second;
6666
}
6767

68-
boost::any InMemoryCache::Get(const std::string& key) {
68+
olp::porting::any InMemoryCache::Get(const std::string& key) {
6969
std::lock_guard<std::mutex> lock{mutex_};
7070
auto it = item_tuples_.Find(key);
7171
if (it != item_tuples_.end()) {

olp-cpp-sdk-core/src/client/repository/ApiCacheRepository.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ porting::optional<std::string> ApiCacheRepository::Get(
5555
return porting::none;
5656
}
5757

58-
return boost::any_cast<std::string>(url);
58+
return olp::porting::any_cast<std::string>(url);
5959
}
6060

6161
} // namespace repository

olp-cpp-sdk-core/tests/cache/DefaultCacheImplTest.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ TEST_F(DefaultCacheImplTest, MutableCacheExpired) {
431431

432432
ASSERT_NE(value.get(), nullptr);
433433
ASSERT_EQ(value2.type(), typeid(std::string));
434-
auto str = boost::any_cast<std::string>(value2);
434+
auto str = olp::porting::any_cast<std::string>(value2);
435435
EXPECT_EQ(str, data_string);
436436

437437
std::this_thread::sleep_for(std::chrono::seconds(3));
@@ -473,7 +473,7 @@ TEST_F(DefaultCacheImplTest, ProtectedCacheExpired) {
473473

474474
EXPECT_FALSE(value.get() == nullptr);
475475
EXPECT_EQ(value2.type(), typeid(std::string));
476-
auto str = boost::any_cast<std::string>(value2);
476+
auto str = olp::porting::any_cast<std::string>(value2);
477477
EXPECT_EQ(str, data_string);
478478

479479
std::this_thread::sleep_for(std::chrono::seconds(3));
@@ -892,7 +892,7 @@ TEST_F(DefaultCacheImplTest, ProtectTest) {
892892
auto key2_data_read =
893893
cache.Get(key2, [](const std::string& data) { return data; });
894894
ASSERT_FALSE(key2_data_read.empty());
895-
ASSERT_EQ(key2_data_string, boost::any_cast<std::string>(key2_data_read));
895+
ASSERT_EQ(key2_data_string, olp::porting::any_cast<std::string>(key2_data_read));
896896
}
897897
{
898898
SCOPED_TRACE("Check if key still protected exist after closing");
@@ -901,7 +901,7 @@ TEST_F(DefaultCacheImplTest, ProtectTest) {
901901
auto key2_data_read =
902902
cache.Get(key2, [](const std::string& data) { return data; });
903903
ASSERT_FALSE(key2_data_read.empty());
904-
ASSERT_EQ(key2_data_string, boost::any_cast<std::string>(key2_data_read));
904+
ASSERT_EQ(key2_data_string, olp::porting::any_cast<std::string>(key2_data_read));
905905
ASSERT_TRUE(cache.IsProtected(key2));
906906
ASSERT_TRUE(cache.IsProtected(key3));
907907
// key which do not exist

olp-cpp-sdk-core/tests/cache/DefaultCacheTest.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void BasicCacheTestWithSettings(const olp::cache::CacheSettings& settings) {
5555
cache.Get("key", [](const std::string& data) { return data; });
5656

5757
EXPECT_FALSE(data_read.empty());
58-
EXPECT_EQ(data_string, boost::any_cast<std::string>(data_read));
58+
EXPECT_EQ(data_string, olp::porting::any_cast<std::string>(data_read));
5959
}
6060

6161
{
@@ -218,7 +218,7 @@ TEST(DefaultCacheTest, BasicTest) {
218218
auto key1DataRead =
219219
cache.Get("key1", [](const std::string& data) { return data; });
220220
ASSERT_FALSE(key1DataRead.empty());
221-
ASSERT_EQ(key1DataString, boost::any_cast<std::string>(key1DataRead));
221+
ASSERT_EQ(key1DataString, olp::porting::any_cast<std::string>(key1DataRead));
222222
ASSERT_TRUE(cache.Clear());
223223
}
224224

@@ -232,7 +232,7 @@ TEST(DefaultCacheTest, BasicInMemTest) {
232232
auto key1DataRead =
233233
cache.Get("key1", [](const std::string& data) { return data; });
234234
ASSERT_FALSE(key1DataRead.empty());
235-
ASSERT_EQ(key1DataString, boost::any_cast<std::string>(key1DataRead));
235+
ASSERT_EQ(key1DataString, olp::porting::any_cast<std::string>(key1DataRead));
236236
ASSERT_TRUE(cache.Clear());
237237
}
238238

@@ -250,7 +250,7 @@ TEST(DefaultCacheTest, MemSizeTest) {
250250
auto key1DataRead =
251251
cache.Get(key1, [](const std::string& data) { return data; });
252252
ASSERT_FALSE(key1DataRead.empty());
253-
ASSERT_EQ(key1DataString, boost::any_cast<std::string>(key1DataRead));
253+
ASSERT_EQ(key1DataString, olp::porting::any_cast<std::string>(key1DataRead));
254254
}
255255

256256
std::string key2{"key2"};
@@ -261,7 +261,7 @@ TEST(DefaultCacheTest, MemSizeTest) {
261261
auto key2DataRead =
262262
cache.Get(key2, [](const std::string& data) { return data; });
263263
ASSERT_FALSE(key2DataRead.empty());
264-
ASSERT_EQ(key2DataString, boost::any_cast<std::string>(key2DataRead));
264+
ASSERT_EQ(key2DataString, olp::porting::any_cast<std::string>(key2DataRead));
265265

266266
auto key1DataRead =
267267
cache.Get(key1, [](const std::string& data) { return data; });
@@ -282,7 +282,7 @@ TEST(DefaultCacheTest, BasicDiskTest) {
282282
auto key1DataRead =
283283
cache.Get("key1", [](const std::string& data) { return data; });
284284
ASSERT_FALSE(key1DataRead.empty());
285-
ASSERT_EQ(key1DataString, boost::any_cast<std::string>(key1DataRead));
285+
ASSERT_EQ(key1DataString, olp::porting::any_cast<std::string>(key1DataRead));
286286
ASSERT_TRUE(cache.Clear());
287287
}
288288

@@ -367,7 +367,7 @@ TEST(DefaultCacheTest, ProtectedCacheTest) {
367367
auto key1_data_read =
368368
cache.Get(key1, [](const std::string& data) { return data; });
369369
ASSERT_FALSE(key1_data_read.empty());
370-
ASSERT_EQ(key1_data_string, boost::any_cast<std::string>(key1_data_read));
370+
ASSERT_EQ(key1_data_string, olp::porting::any_cast<std::string>(key1_data_read));
371371
}
372372
{
373373
SCOPED_TRACE("Get from protected - missing key");
@@ -402,7 +402,7 @@ TEST(DefaultCacheTest, ProtectedCacheTest) {
402402
auto key2_data_read =
403403
cache.Get(key2, [](const std::string& data) { return data; });
404404
ASSERT_FALSE(key2_data_read.empty());
405-
ASSERT_EQ(key2_data_string, boost::any_cast<std::string>(key2_data_read));
405+
ASSERT_EQ(key2_data_string, olp::porting::any_cast<std::string>(key2_data_read));
406406
ASSERT_TRUE(cache.Clear());
407407
}
408408
{
@@ -417,7 +417,7 @@ TEST(DefaultCacheTest, ProtectedCacheTest) {
417417
auto key1_data_read =
418418
cache.Get(key1, [](const std::string& data) { return data; });
419419
ASSERT_FALSE(key1_data_read.empty());
420-
ASSERT_EQ(key1_data_string, boost::any_cast<std::string>(key1_data_read));
420+
ASSERT_EQ(key1_data_string, olp::porting::any_cast<std::string>(key1_data_read));
421421
}
422422
{
423423
SCOPED_TRACE("Put to protected - blocked");
@@ -440,7 +440,7 @@ TEST(DefaultCacheTest, ProtectedCacheTest) {
440440
auto key1_data_read =
441441
cache.Get(key1, [](const std::string& data) { return data; });
442442
ASSERT_FALSE(key1_data_read.empty());
443-
ASSERT_EQ(key1_data_string, boost::any_cast<std::string>(key1_data_read));
443+
ASSERT_EQ(key1_data_string, olp::porting::any_cast<std::string>(key1_data_read));
444444
}
445445

446446
{

olp-cpp-sdk-core/tests/cache/InMemoryCacheTest.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ TEST(InMemoryCacheTest, NoLimit) {
6262

6363
auto i0 = cache.Get("key0");
6464
ASSERT_FALSE(i0.empty());
65-
ASSERT_EQ("value0", boost::any_cast<std::string>(i0));
65+
ASSERT_EQ("value0", olp::porting::any_cast<std::string>(i0));
6666

6767
auto i9 = cache.Get("key9");
6868
ASSERT_FALSE(i9.empty());
69-
ASSERT_EQ("value9", boost::any_cast<std::string>(i9));
69+
ASSERT_EQ("value9", olp::porting::any_cast<std::string>(i9));
7070

7171
ASSERT_TRUE(cache.Get("key10").empty());
7272
}
@@ -127,14 +127,14 @@ TEST(InMemoryCacheTest, PutOverwritesPrevious) {
127127
ASSERT_EQ(1u, cache.Size());
128128
auto value = cache.Get(key);
129129
ASSERT_FALSE(value.empty());
130-
ASSERT_EQ(orig_value, boost::any_cast<std::string>(value));
130+
ASSERT_EQ(orig_value, olp::porting::any_cast<std::string>(value));
131131

132132
std::string updated_value("updatedValue");
133133
cache.Put(key, updated_value);
134134

135135
value = cache.Get(key);
136136
ASSERT_FALSE(value.empty());
137-
ASSERT_EQ(updated_value, boost::any_cast<std::string>(value));
137+
ASSERT_EQ(updated_value, olp::porting::any_cast<std::string>(value));
138138
}
139139

140140
TEST(InMemoryCacheTest, InsertOverLimit) {
@@ -145,7 +145,7 @@ TEST(InMemoryCacheTest, InsertOverLimit) {
145145
ASSERT_TRUE(cache.Get("key0").empty());
146146
auto i1 = cache.Get("key1");
147147
ASSERT_FALSE(i1.empty());
148-
ASSERT_EQ("value1", boost::any_cast<std::string>(i1));
148+
ASSERT_EQ("value1", olp::porting::any_cast<std::string>(i1));
149149
}
150150

151151
TEST(InMemoryCacheTest, GetReorders) {
@@ -155,14 +155,14 @@ TEST(InMemoryCacheTest, GetReorders) {
155155

156156
auto i0 = cache.Get("key0");
157157
ASSERT_FALSE(i0.empty());
158-
ASSERT_EQ("value0", boost::any_cast<std::string>(i0));
158+
ASSERT_EQ("value0", olp::porting::any_cast<std::string>(i0));
159159

160160
Populate(cache, 1, 2);
161161
ASSERT_TRUE(cache.Get("key1").empty());
162162

163163
auto i2 = cache.Get("key2");
164164
ASSERT_FALSE(i2.empty());
165-
ASSERT_EQ("value2", boost::any_cast<std::string>(i2));
165+
ASSERT_EQ("value2", olp::porting::any_cast<std::string>(i2));
166166
}
167167

168168
TEST(InMemoryCacheTest, GetSingleExpired) {
@@ -370,7 +370,7 @@ TEST(InMemoryCacheTest, ClassBasedCustomCost) {
370370
auto model_item = std::get<2>(tuple);
371371
std::size_t result(1u);
372372

373-
if (auto data_container = boost::any_cast<Data>(model_item)) {
373+
if (auto data_container = olp::porting::any_cast<Data>(model_item)) {
374374
auto data_size = data_container->size();
375375
result = (data_size > 0) ? data_size : result;
376376
}

olp-cpp-sdk-dataservice-read/src/repositories/ApiCacheRepository.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ porting::optional<std::string> ApiCacheRepository::Get(
5757
return olp::porting::none;
5858
}
5959

60-
return boost::any_cast<std::string>(url);
60+
return olp::porting::any_cast<std::string>(url);
6161
}
6262

6363
} // namespace repository

olp-cpp-sdk-dataservice-read/src/repositories/CatalogCacheRepository.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ porting::optional<model::Catalog> CatalogCacheRepository::Get() {
7777
return olp::porting::none;
7878
}
7979

80-
return boost::any_cast<model::Catalog>(cached_catalog);
80+
return olp::porting::any_cast<model::Catalog>(cached_catalog);
8181
}
8282

8383
bool CatalogCacheRepository::PutVersion(const model::VersionResponse& version) {
@@ -102,7 +102,7 @@ porting::optional<model::VersionResponse> CatalogCacheRepository::GetVersion() {
102102
if (cached_version.empty()) {
103103
return olp::porting::none;
104104
}
105-
return boost::any_cast<model::VersionResponse>(cached_version);
105+
return olp::porting::any_cast<model::VersionResponse>(cached_version);
106106
}
107107

108108
bool CatalogCacheRepository::Clear() {

olp-cpp-sdk-dataservice-read/src/repositories/PartitionsCacheRepository.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ porting::optional<model::LayerVersions> PartitionsCacheRepository::Get(
190190
}
191191

192192
return std::move(
193-
boost::any_cast<model::LayerVersions&&>(cached_layer_versions));
193+
olp::porting::any_cast<model::LayerVersions&&>(cached_layer_versions));
194194
}
195195

196196
client::ApiNoResponse PartitionsCacheRepository::Put(

olp-cpp-sdk-dataservice-write/src/ApiClientLookup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ ApiClientLookup::ApiClientResponse ApiClientLookup::LookupApiClient(
149149
auto url =
150150
cache->Get(cache_key, [](const std::string& value) { return value; });
151151
if (!url.empty()) {
152-
auto base_url = boost::any_cast<std::string>(url);
152+
auto base_url = olp::porting::any_cast<std::string>(url);
153153
OLP_SDK_LOG_INFO_F(kLogTag, "LookupApiClient(%s, %s) -> from cache",
154154
service.c_str(), service_version.c_str());
155155
client::OlpClient client(settings, base_url);

olp-cpp-sdk-dataservice-write/src/CatalogSettings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ CatalogSettings::LayerSettingsResult CatalogSettings::GetLayerSettings(
112112
.str());
113113
}
114114

115-
const auto& catalog = boost::any_cast<const model::Catalog&>(cached_catalog);
115+
const auto& catalog = olp::porting::any_cast<const model::Catalog&>(cached_catalog);
116116
return GetLayerSettingsFromModel(catalog, layer_id);
117117
}
118118

0 commit comments

Comments
 (0)