15 #ifndef Om_Source_CodePointStringBackSource_
21 #ifndef Om_Macro_Precompilation_
23 #include "boost/test/unit_test.hpp"
31 BOOST_AUTO_TEST_SUITE(CodePointStringBackSourceTest)
33 BOOST_AUTO_TEST_CASE(ValidTest) {
34 std::string theString(
43 CodePointStringBackSource<std::string::const_iterator> theSource(
114 BOOST_AUTO_TEST_CASE(InvalidNoTrailingTest) {
115 std::string theString(
120 CodePointStringBackSource<std::string::const_iterator> theSource(
151 BOOST_AUTO_TEST_CASE(InvalidInsufficientTrailingTest) {
152 std::string theString(
157 CodePointStringBackSource<std::string::const_iterator> theSource(
188 BOOST_AUTO_TEST_CASE(InvalidExtraTrailingTest) {
189 std::string theString(
195 CodePointStringBackSource<std::string::const_iterator> theSource(
236 BOOST_AUTO_TEST_CASE(InvalidMissingLeadingTest) {
237 std::string theString(
242 CodePointStringBackSource<std::string::const_iterator> theSource(
273 BOOST_AUTO_TEST_CASE(InvalidEarlyTerminationTest) {
274 std::string theString(
278 CodePointStringBackSource<std::string::const_iterator> theSource(
299 BOOST_AUTO_TEST_SUITE_END()
311 #ifndef Om_Macro_Precompilation_
313 #include "boost/swap.hpp"
320 template <typename ThisStringIterator>
323 Om::Source::CodePointStringBackSource<ThisStringIterator>
328 inline Type_::CodePointStringBackSource(
329 ThisStringIterator theStringStart,
330 ThisStringIterator
const theStringEnd
332 thisStringIterator(theStringStart),
333 thisCodePointIterator(theStringEnd),
334 thisCodePointEnd(theStringEnd),
340 inline Type_ & Type_::operator =(CodePointStringBackSource theCodePointStringBackSource) {
341 this->Swap(theCodePointStringBackSource);
346 inline bool Type_::operator !()
const {
347 return this->thisCodePointEnd == this->thisCodePointIterator;
351 inline std::string & Type_::operator *()
const {
352 assert(this->thisCodePointEnd != this->thisCodePointIterator);
353 return this->thisCodePoint;
357 inline bool Type_::Equals(CodePointStringBackSource
const & theCodePointStringBackSource)
const {
358 return this->thisCodePointIterator == theCodePointStringBackSource.thisCodePointIterator;
362 inline void Type_::Pop() {
363 assert(this->thisCodePointEnd != this->thisCodePointIterator);
364 this->thisCodePointEnd = this->thisCodePointIterator;
365 this->thisCodePoint.clear();
370 inline void Type_::Swap(CodePointStringBackSource & theCodePointStringBackSource) {
372 this->thisStringIterator,
373 theCodePointStringBackSource.thisStringIterator
376 this->thisCodePointIterator,
377 theCodePointStringBackSource.thisCodePointIterator
380 this->thisCodePointEnd,
381 theCodePointStringBackSource.thisCodePointEnd
385 theCodePointStringBackSource.thisCodePoint
392 inline void Type_::Update() {
393 assert(this->thisCodePointEnd == this->thisCodePointIterator);
395 this->thisCodePoint.empty()
397 if (this->thisStringIterator == this->thisCodePointIterator) {
401 int theTrailCount = 0;
405 assert(this->thisStringIterator != this->thisCodePointIterator);
406 char const theCodeUnit = *--this->thisCodePointIterator;
408 Utf8::is_lead(theCodeUnit)
410 int const theCorrectTrailCount = Utf8::trail_length(theCodeUnit);
411 if (theCorrectTrailCount == theTrailCount) {
412 this->thisCodePoint.assign(
413 this->thisCodePointIterator,
414 this->thisCodePointEnd
418 if (theCorrectTrailCount < theTrailCount) {
419 this->thisCodePointIterator += (theCorrectTrailCount + 1);
423 if (this->thisStringIterator == this->thisCodePointIterator) {
427 this->thisCodePoint =
"\xEF\xBF\xBD" ;
436 template <typename TheStringIterator>
439 Om::Source::CodePointStringBackSource<TheStringIterator>
443 Type_
const & theFirst,
444 Type_
const & theSecond
446 return theFirst.Equals(theSecond);
451 Type_
const & theFirst,
452 Type_
const & theSecond
454 return !theFirst.Equals(theSecond);
464 theFirst.Swap(theSecond);
bool operator==(CodePointSource< TheCodeUnitIterator > const &, CodePointSource< TheCodeUnitIterator > const &)
bool operator!=(CodePointSource< TheCodeUnitIterator > const &, CodePointSource< TheCodeUnitIterator > const &)
void swap(Om::Language::Expression &, Om::Language::Expression &)