xlnt/source/string_table.cpp

32 lines
610 B
C++
Raw Normal View History

2014-05-22 07:17:56 +08:00
#include <stdexcept>
2014-06-06 04:19:31 +08:00
#include "common/string_table.hpp"
2014-05-21 22:20:30 +08:00
namespace xlnt {
int string_table::operator[](const std::string &key) const
{
for(std::size_t i = 0; i < strings_.size(); i++)
{
if(key == strings_[i])
{
return (int)i;
}
}
throw std::runtime_error("bad string");
}
void string_table_builder::add(const std::string &string)
{
for(std::size_t i = 0; i < table_.strings_.size(); i++)
{
if(string == table_.strings_[i])
{
return;
}
}
table_.strings_.push_back(string);
}
} // namespace xlnt