Added peek_next
git-svn-id: http://svn.code.sf.net/p/utfcpp/code@82 a809a056-fc17-0410-9590-b4f493f8b08e
This commit is contained in:
parent
aa6d8ff2f6
commit
3a04fda526
3 changed files with 24 additions and 1 deletions
|
@ -152,6 +152,12 @@ namespace utf8
|
|||
return cp;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t peek_next(octet_iterator it, octet_iterator end)
|
||||
{
|
||||
return next(it, end);
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t prior(octet_iterator& it, octet_iterator start)
|
||||
{
|
||||
|
|
|
@ -56,6 +56,7 @@ namespace utf8
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t next(octet_iterator& it)
|
||||
{
|
||||
|
@ -87,6 +88,12 @@ namespace utf8
|
|||
return cp;
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t peek_next(octet_iterator it)
|
||||
{
|
||||
return next(it);
|
||||
}
|
||||
|
||||
template <typename octet_iterator>
|
||||
uint32_t prior(octet_iterator& it)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,6 @@ int main()
|
|||
end = append(0x10346, u);
|
||||
assert (u[0] == 0xf0 && u[1] == 0x90 && u[2] == 0x8d && u[3] == 0x86 && u[4] == 0);
|
||||
|
||||
|
||||
|
||||
//next
|
||||
char* twochars = "\xe6\x97\xa5\xd1\x88";
|
||||
|
@ -43,6 +42,12 @@ int main()
|
|||
assert (cp == 0x0448);
|
||||
assert (w == threechars + 9);
|
||||
|
||||
//peek_next
|
||||
char* const cw = twochars;
|
||||
cp = peek_next(cw, cw + 6);
|
||||
assert (cp == 0x65e5);
|
||||
assert (cw == twochars);
|
||||
|
||||
//prior
|
||||
w = twochars + 3;
|
||||
cp = prior (w, twochars);
|
||||
|
@ -197,6 +202,11 @@ int main()
|
|||
assert (cp == 0x0448);
|
||||
assert (w == threechars + 9);
|
||||
|
||||
//peek_next
|
||||
cp = unchecked::peek_next(cw);
|
||||
assert (cp == 0x65e5);
|
||||
assert (cw == twochars);
|
||||
|
||||
|
||||
//previous (calls prior internally)
|
||||
|
||||
|
|
Loading…
Reference in a new issue