diff options
author | John Wiegley <johnw@newartisans.com> | 2010-03-07 22:47:25 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-03-08 01:11:55 -0500 |
commit | 8fef8689296bfe491cbf54426ac468035152a94b (patch) | |
tree | 3cdc821cc9a3b34f8be21925b8799ef339da3a17 /src/unistring.h | |
parent | 75b7294a6db10e7f7b18b6aeef1aa0f568124a1d (diff) | |
download | fork-ledger-8fef8689296bfe491cbf54426ac468035152a94b.tar.gz fork-ledger-8fef8689296bfe491cbf54426ac468035152a94b.tar.bz2 fork-ledger-8fef8689296bfe491cbf54426ac468035152a94b.zip |
Added find() and operator[] to unistring
Diffstat (limited to 'src/unistring.h')
-rw-r--r-- | src/unistring.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/unistring.h b/src/unistring.h index 5413ef14..d42f2b28 100644 --- a/src/unistring.h +++ b/src/unistring.h @@ -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, |