diff --git a/persistent-data/data-structures/btree.h b/persistent-data/data-structures/btree.h index 8582ad6..0dd9f37 100644 --- a/persistent-data/data-structures/btree.h +++ b/persistent-data/data-structures/btree.h @@ -76,7 +76,6 @@ namespace persistent_data { namespace btree_detail { using namespace base; using namespace std; - using namespace boost; uint32_t const BTREE_CSUM_XOR = 121107; @@ -164,7 +163,7 @@ namespace persistent_data { // Various searches int bsearch(uint64_t key, int want_hi) const; - optional exact_search(uint64_t key) const; + boost::optional exact_search(uint64_t key) const; int lower_bound(uint64_t key) const; template @@ -211,7 +210,7 @@ namespace persistent_data { const_cast(b.data().raw()))); } - class ro_spine : private noncopyable { + class ro_spine : private boost::noncopyable { public: ro_spine(transaction_manager::ptr tm, typename block_manager<>::validator::ptr v) @@ -232,7 +231,7 @@ namespace persistent_data { std::list::read_ref> spine_; }; - class shadow_spine : private noncopyable { + class shadow_spine : private boost::noncopyable { public: typedef transaction_manager::read_ref read_ref; typedef transaction_manager::write_ref write_ref; diff --git a/persistent-data/data-structures/btree.tcc b/persistent-data/data-structures/btree.tcc index 1655bbb..9674ade 100644 --- a/persistent-data/data-structures/btree.tcc +++ b/persistent-data/data-structures/btree.tcc @@ -294,17 +294,17 @@ namespace persistent_data { } template - optional + boost::optional node_ref::exact_search(uint64_t key) const { int i = bsearch(key, 0); if (i < 0 || static_cast(i) >= get_nr_entries()) - return optional(); + return boost::optional(); if (key != key_at(i)) - return optional(); + return boost::optional(); - return optional(i); + return boost::optional(i); } template @@ -405,14 +405,14 @@ namespace persistent_data { namespace { template struct lower_bound_search { - static optional search(btree_detail::node_ref n, uint64_t key) { + static boost::optional search(btree_detail::node_ref n, uint64_t key) { return n.lower_bound(key); } }; template struct exact_search { - static optional search(btree_detail::node_ref n, uint64_t key) { + static boost::optional search(btree_detail::node_ref n, uint64_t key) { return n.exact_search(key); } }; @@ -428,7 +428,7 @@ namespace persistent_data { block_address root = root_; for (unsigned level = 0; level < Levels - 1; ++level) { - optional mroot = + boost::optional mroot = lookup_raw >(spine, root, key[level]); if (!mroot) return maybe_value(); @@ -535,7 +535,7 @@ namespace persistent_data { template template - optional + boost::optional btree:: lookup_raw(ro_spine &spine, block_address block, uint64_t key) const { @@ -546,18 +546,18 @@ namespace persistent_data { spine.step(block); node_ref leaf = spine.template get_node(); - optional mi; + boost::optional mi; if (leaf.get_type() == btree_detail::LEAF) { mi = Search::search(leaf, key); if (!mi) - return optional(); - return optional(leaf.value_at(*mi)); + return boost::optional(); + return boost::optional(leaf.value_at(*mi)); } mi = leaf.lower_bound(key); if (!mi || *mi < 0) - return optional(); + return boost::optional(); node_ref internal = spine.template get_node(); block = internal.value_at(*mi); @@ -803,7 +803,7 @@ namespace persistent_data { node_location loc2(loc); loc2.push_key(o.key_at(i)); - loc2.key = optional(); + loc2.key = boost::optional(); walk_tree(v, loc2, o.value_at(i)); } diff --git a/persistent-data/data-structures/btree_checker.h b/persistent-data/data-structures/btree_checker.h index 2791da0..d78505f 100644 --- a/persistent-data/data-structures/btree_checker.h +++ b/persistent-data/data-structures/btree_checker.h @@ -97,7 +97,7 @@ namespace persistent_data { check_max_entries(n) && check_nr_entries(n, loc.is_sub_root()) && check_ordered_keys(n) && - check_parent_key(loc.is_sub_root() ? optional() : loc.key, n)) { + check_parent_key(loc.is_sub_root() ? boost::optional() : loc.key, n)) { if (loc.is_sub_root()) new_root(loc.level()); @@ -115,7 +115,7 @@ namespace persistent_data { check_max_entries(n) && check_nr_entries(n, loc.is_sub_root()) && check_ordered_keys(n) && - check_parent_key(loc.is_sub_root() ? optional() : loc.key, n)) { + check_parent_key(loc.is_sub_root() ? boost::optional() : loc.key, n)) { if (loc.is_sub_root()) new_root(loc.level()); diff --git a/persistent-data/data-structures/btree_damage_visitor.h b/persistent-data/data-structures/btree_damage_visitor.h index 801251b..7fc3998 100644 --- a/persistent-data/data-structures/btree_damage_visitor.h +++ b/persistent-data/data-structures/btree_damage_visitor.h @@ -206,7 +206,7 @@ namespace persistent_data { check_max_entries(n) && check_nr_entries(n, loc.is_sub_root()) && check_ordered_keys(n) && - check_parent_key(loc.is_sub_root() ? optional() : loc.key, n)) { + check_parent_key(loc.is_sub_root() ? boost::optional() : loc.key, n)) { if (loc.is_sub_root()) new_root(loc.level()); @@ -225,7 +225,7 @@ namespace persistent_data { check_max_entries(n) && check_nr_entries(n, loc.is_sub_root()) && check_ordered_keys(n) && - check_parent_key(loc.is_sub_root() ? optional() : loc.key, n)) { + check_parent_key(loc.is_sub_root() ? boost::optional() : loc.key, n)) { if (loc.is_sub_root()) new_root(loc.level()); diff --git a/persistent-data/space-maps/disk.cc b/persistent-data/space-maps/disk.cc index 0f39745..9e435b6 100644 --- a/persistent-data/space-maps/disk.cc +++ b/persistent-data/space-maps/disk.cc @@ -26,12 +26,10 @@ #include "persistent-data/math_utils.h" #include "persistent-data/transaction_manager.h" -using namespace boost; using namespace persistent_data; using namespace std; using namespace sm_disk_detail; - //---------------------------------------------------------------- namespace { @@ -322,7 +320,7 @@ namespace { unsigned bit_begin = (index == begin_index) ? (begin % ENTRIES_PER_BLOCK) : 0; unsigned bit_end = (index == end_index - 1) ? (end % ENTRIES_PER_BLOCK) : ENTRIES_PER_BLOCK; - optional maybe_b = bm.find_free(bit_begin, bit_end); + boost::optional maybe_b = bm.find_free(bit_begin, bit_end); if (maybe_b) { block_address b = (index * ENTRIES_PER_BLOCK) + *maybe_b; return b; @@ -474,7 +472,7 @@ namespace { ref_t lookup_ref_count(block_address b) const { uint64_t key[1] = {b}; - optional mvalue = ref_counts_.lookup(key); + boost::optional mvalue = ref_counts_.lookup(key); if (!mvalue) throw runtime_error("ref count not in tree"); return *mvalue; @@ -572,7 +570,7 @@ namespace { virtual index_entry find_ie(block_address ie_index) const { uint64_t key[1] = {ie_index}; - optional mindex = bitmaps_.lookup(key); + boost::optional mindex = bitmaps_.lookup(key); if (!mindex) throw runtime_error("Couldn't lookup bitmap"); diff --git a/thin-provisioning/metadata_dumper.cc b/thin-provisioning/metadata_dumper.cc index d42e9b7..e173c63 100644 --- a/thin-provisioning/metadata_dumper.cc +++ b/thin-provisioning/metadata_dumper.cc @@ -189,9 +189,9 @@ namespace { void thin_provisioning::metadata_dump(metadata::ptr md, emitter::ptr e, bool repair) { - optional md_snap = md->sb_.metadata_snap_ ? - optional(md->sb_.metadata_snap_) : - optional(); + boost::optional md_snap = md->sb_.metadata_snap_ ? + boost::optional(md->sb_.metadata_snap_) : + boost::optional(); e->begin_superblock("", md->sb_.time_, md->sb_.trans_id_, diff --git a/thin-provisioning/restore_emitter.cc b/thin-provisioning/restore_emitter.cc index c5d7b2d..b1fe870 100644 --- a/thin-provisioning/restore_emitter.cc +++ b/thin-provisioning/restore_emitter.cc @@ -19,7 +19,6 @@ #include "thin-provisioning/restore_emitter.h" #include "thin-provisioning/superblock.h" -using namespace boost; using namespace std; using namespace thin_provisioning; @@ -46,11 +45,11 @@ namespace { uint64_t trans_id, uint32_t data_block_size, uint64_t nr_data_blocks, - optional metadata_snap) { + boost::optional metadata_snap) { in_superblock_ = true; nr_data_blocks_ = nr_data_blocks; superblock &sb = md_->sb_; - memcpy(&sb.uuid_, &uuid, sizeof(&sb.uuid_)); + memcpy(&sb.uuid_, &uuid, sizeof(sb.uuid_)); sb.time_ = time; sb.trans_id_ = trans_id; sb.data_block_size_ = data_block_size; @@ -83,7 +82,7 @@ namespace { md_->details_->insert(key, details); current_mapping_ = empty_mapping_->clone(); - current_device_ = optional(dev); + current_device_ = boost::optional(dev); } virtual void end_device() { @@ -92,7 +91,7 @@ namespace { md_->mappings_top_level_->insert(key, current_mapping_->get_root()); md_->mappings_->set_root(md_->mappings_top_level_->get_root()); // FIXME: ugly - current_device_ = optional(); + current_device_ = boost::optional(); } virtual void begin_named_mapping(std::string const &name) { @@ -147,7 +146,7 @@ namespace { metadata::ptr md_; bool in_superblock_; block_address nr_data_blocks_; - optional current_device_; + boost::optional current_device_; single_mapping_tree::ptr current_mapping_; single_mapping_tree::ptr empty_mapping_; }; diff --git a/thin-provisioning/thin_pool.cc b/thin-provisioning/thin_pool.cc index 4c081e8..cb2655e 100644 --- a/thin-provisioning/thin_pool.cc +++ b/thin-provisioning/thin_pool.cc @@ -73,7 +73,7 @@ void thin::set_snapshot_time(uint32_t time) { uint64_t key[1] = { dev_ }; - optional mdetail = pool_->md_->details_->lookup(key); + boost::optional mdetail = pool_->md_->details_->lookup(key); if (!mdetail) throw runtime_error("no such device"); @@ -85,7 +85,7 @@ block_address thin::get_mapped_blocks() const { uint64_t key[1] = { dev_ }; - optional mdetail = pool_->md_->details_->lookup(key); + boost::optional mdetail = pool_->md_->details_->lookup(key); if (!mdetail) throw runtime_error("no such device"); @@ -96,7 +96,7 @@ void thin::set_mapped_blocks(block_address count) { uint64_t key[1] = { dev_ }; - optional mdetail = pool_->md_->details_->lookup(key); + boost::optional mdetail = pool_->md_->details_->lookup(key); if (!mdetail) throw runtime_error("no such device"); @@ -138,7 +138,7 @@ thin_pool::create_snap(thin_dev_t dev, thin_dev_t origin) uint64_t snap_key[1] = {dev}; uint64_t origin_key[1] = {origin}; - optional mtree_root = md_->mappings_top_level_->lookup(origin_key); + boost::optional mtree_root = md_->mappings_top_level_->lookup(origin_key); if (!mtree_root) throw std::runtime_error("unknown origin"); @@ -186,7 +186,7 @@ thin_pool::get_metadata_snap() const block_address thin_pool::alloc_data_block() { - optional mb = md_->data_sm_->new_block(); + boost::optional mb = md_->data_sm_->new_block(); if (!mb) throw runtime_error("couldn't allocate new block"); @@ -221,7 +221,7 @@ thin::ptr thin_pool::open_thin(thin_dev_t dev) { uint64_t key[1] = {dev}; - optional mdetails = md_->details_->lookup(key); + boost::optional mdetails = md_->details_->lookup(key); if (!mdetails) throw runtime_error("no such device"); diff --git a/thin-provisioning/xml_format.cc b/thin-provisioning/xml_format.cc index 86f5a35..7125b4c 100644 --- a/thin-provisioning/xml_format.cc +++ b/thin-provisioning/xml_format.cc @@ -27,7 +27,6 @@ #include #include -using namespace boost; using namespace std; using namespace thin_provisioning; @@ -51,7 +50,7 @@ namespace { uint64_t trans_id, uint32_t data_block_size, uint64_t nr_data_blocks, - optional metadata_snap) { + boost::optional metadata_snap) { indent(); out_ << "(it->second); + return boost::lexical_cast(it->second); } template - optional get_opt_attr(attributes const &attr, string const &key) { - typedef optional rtype; + boost::optional get_opt_attr(attributes const &attr, string const &key) { + typedef boost::optional rtype; attributes::const_iterator it = attr.find(key); if (it == attr.end()) return rtype(); - return rtype(lexical_cast(it->second)); + return rtype(boost::lexical_cast(it->second)); } void parse_superblock(emitter *e, attributes const &attr) { diff --git a/unit-tests/array_t.cc b/unit-tests/array_t.cc index fe4b2b2..fbbc197 100644 --- a/unit-tests/array_t.cc +++ b/unit-tests/array_t.cc @@ -24,7 +24,6 @@ #include using namespace std; -using namespace boost; using namespace persistent_data; using namespace testing; diff --git a/unit-tests/btree_damage_visitor_t.cc b/unit-tests/btree_damage_visitor_t.cc index 441cc38..e33f9aa 100644 --- a/unit-tests/btree_damage_visitor_t.cc +++ b/unit-tests/btree_damage_visitor_t.cc @@ -314,7 +314,7 @@ namespace { transaction_manager::ptr tm_; thing_traits::ref_counter rc_; - optional layout_; + boost::optional layout_; value_visitor_mock value_visitor_; damage_visitor_mock damage_visitor_; @@ -578,8 +578,8 @@ TEST_F(BTreeDamageVisitorTests, damaged_internal) node_info n = layout_->random_node(is_internal); - optional begin = n.keys.begin_; - optional end = n.keys.end_; + boost::optional begin = n.keys.begin_; + boost::optional end = n.keys.end_; trash_block(n.b);