#include <iostream>
#include <string>
#include <vector>
#include "bm.h"
#include "bmstrsparsevec.h"
#include "bmundef.h"
using namespace std;
typedef bm::bvector<> bvector_type;
typedef bm::str_sparse_vector<char, bvector_type, 32> str_sv_type;
int main(void)
{
try
{
str_sv_type str_sv(bm::use_null);
const char* s0 = "asz1234";
std::string str1 = "aqw1234";
std::string str3 = "54z";
std::string str00 = "00";
str_sv.set(0, s0); str_sv.push_back(str1);
str_sv.assign(3, str3);
{
auto bi = str_sv.get_back_inserter();
bi = "456"; bi.add_null(); bi = (const char*)0;
bi.flush(); }
str_sv.set_null(str_sv.size());
std::cout << "sv size()=" << str_sv.size() << endl;
for (str_sv_type::size_type i = 0; i < str_sv.size(); ++i)
{
if (str_sv[i].is_null())
cout << i << ":NULL" << endl;
else
{
const char* s = str_sv[i];
cout << i << ":" << s << endl;
}
} cout << endl;
str_sv.clear_range(4, 7, true);
{
str_sv_type::const_iterator it = str_sv.begin();
str_sv_type::const_iterator it_end = str_sv.end();
for (; it != it_end; ++it)
{
if (it.is_null())
cout << "NULL" << endl;
else
cout << *it << endl;
} }
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}