Added find() and operator[] to unistring
This commit is contained in:
parent
75b7294a6d
commit
8fef868929
1 changed files with 19 additions and 0 deletions
|
|
@ -55,6 +55,8 @@ namespace ledger {
|
|||
class unistring
|
||||
{
|
||||
public:
|
||||
static const std::size_t npos = static_cast<std::size_t>(-1);
|
||||
|
||||
std::vector<boost::uint32_t> utf32chars;
|
||||
|
||||
unistring() {
|
||||
|
|
@ -96,6 +98,23 @@ public:
|
|||
|
||||
return utf8result;
|
||||
}
|
||||
|
||||
std::size_t find(const boost::uint32_t __s, std::size_t __pos = 0) const {
|
||||
std::size_t idx = 0;
|
||||
foreach (const boost::uint32_t& ch, utf32chars) {
|
||||
if (idx >= __pos && ch == __s)
|
||||
return idx;
|
||||
idx++;
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
|
||||
boost::uint32_t& operator[](const std::size_t index) {
|
||||
return utf32chars[index];
|
||||
}
|
||||
const boost::uint32_t& operator[](const std::size_t index) const {
|
||||
return utf32chars[index];
|
||||
}
|
||||
};
|
||||
|
||||
inline void justify(std::ostream& out,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue