Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb_re2::CharClassBuilder Class Reference

Public Types

typedef RuneRangeSet::iterator iterator

Public Member Functions

iterator begin ()
iterator end ()
int size ()
bool empty ()
bool full ()
bool Contains (Rune r)
bool FoldsASCII ()
bool AddRange (Rune lo, Rune hi)
CharClassBuilder * Copy ()
void AddCharClass (CharClassBuilder *cc)
void Negate ()
void RemoveAbove (Rune r)
CharClass * GetCharClass ()
void AddRangeFlags (Rune lo, Rune hi, Regexp::ParseFlags parse_flags)

Private Member Functions

 CharClassBuilder (const CharClassBuilder &)=delete
CharClassBuilder & operator= (const CharClassBuilder &)=delete

Private Attributes

uint32_t upper_
uint32_t lower_
int nrunes_
RuneRangeSet ranges_

Static Private Attributes

static const uint32_t AlphaMask = (1<<26) - 1

Constructor & Destructor Documentation

◆ CharClassBuilder()

duckdb_re2::CharClassBuilder::CharClassBuilder ( )
473703 {
473704 nrunes_ = 0;
473705 upper_ = 0;
473706 lower_ = 0;
473707}

Member Function Documentation

◆ begin()

iterator duckdb_re2::CharClassBuilder::begin ( )
inline
322816{ return ranges_.begin(); }

◆ end()

iterator duckdb_re2::CharClassBuilder::end ( )
inline
322817{ return ranges_.end(); }

◆ size()

int duckdb_re2::CharClassBuilder::size ( )
inline
322819{ return nrunes_; }

◆ empty()

bool duckdb_re2::CharClassBuilder::empty ( )
inline
322820{ return nrunes_ == 0; }

◆ full()

bool duckdb_re2::CharClassBuilder::full ( )
inline
322821{ return nrunes_ == Runemax+1; }

◆ Contains()

bool duckdb_re2::CharClassBuilder::Contains ( Rune r)
473781 {
473782 return ranges_.find(RuneRange(r, r)) != end();
473783}

◆ FoldsASCII()

bool duckdb_re2::CharClassBuilder::FoldsASCII ( )
473786 {
473787 return ((upper_ ^ lower_) & AlphaMask) == 0;
473788}

◆ AddRange()

bool duckdb_re2::CharClassBuilder::AddRange ( Rune lo,
Rune hi )
473710 {
473711 if (hi < lo)
473712 return false;
473713
473714 if (lo <= 'z' && hi >= 'A') {
473715 // Overlaps some alpha, maybe not all.
473716 // Update bitmaps telling which ASCII letters are in the set.
473717 Rune lo1 = std::max<Rune>(lo, 'A');
473718 Rune hi1 = std::min<Rune>(hi, 'Z');
473719 if (lo1 <= hi1)
473720 upper_ |= ((1 << (hi1 - lo1 + 1)) - 1) << (lo1 - 'A');
473721
473722 lo1 = std::max<Rune>(lo, 'a');
473723 hi1 = std::min<Rune>(hi, 'z');
473724 if (lo1 <= hi1)
473725 lower_ |= ((1 << (hi1 - lo1 + 1)) - 1) << (lo1 - 'a');
473726 }
473727
473728 { // Check whether lo, hi is already in the class.
473729 iterator it = ranges_.find(RuneRange(lo, lo));
473730 if (it != end() && it->lo <= lo && hi <= it->hi)
473731 return false;
473732 }
473733
473734 // Look for a range abutting lo on the left.
473735 // If it exists, take it out and increase our range.
473736 if (lo > 0) {
473737 iterator it = ranges_.find(RuneRange(lo-1, lo-1));
473738 if (it != end()) {
473739 lo = it->lo;
473740 if (it->hi > hi)
473741 hi = it->hi;
473742 nrunes_ -= it->hi - it->lo + 1;
473743 ranges_.erase(it);
473744 }
473745 }
473746
473747 // Look for a range abutting hi on the right.
473748 // If it exists, take it out and increase our range.
473749 if (hi < Runemax) {
473750 iterator it = ranges_.find(RuneRange(hi+1, hi+1));
473751 if (it != end()) {
473752 hi = it->hi;
473753 nrunes_ -= it->hi - it->lo + 1;
473754 ranges_.erase(it);
473755 }
473756 }
473757
473758 // Look for ranges between lo and hi. Take them out.
473759 // This is only safe because the set has no overlapping ranges.
473760 // We've already removed any ranges abutting lo and hi, so
473761 // any that overlap [lo, hi] must be contained within it.
473762 for (;;) {
473763 iterator it = ranges_.find(RuneRange(lo, hi));
473764 if (it == end())
473765 break;
473766 nrunes_ -= it->hi - it->lo + 1;
473767 ranges_.erase(it);
473768 }
473769
473770 // Finally, add [lo, hi].
473771 nrunes_ += hi - lo + 1;
473772 ranges_.insert(RuneRange(lo, hi));
473773 return true;
473774}

◆ Copy()

CharClassBuilder * duckdb_re2::CharClassBuilder::Copy ( )
473790 {
473791 CharClassBuilder* cc = new CharClassBuilder;
473792 for (iterator it = begin(); it != end(); ++it)
473793 cc->ranges_.insert(RuneRange(it->lo, it->hi));
473794 cc->upper_ = upper_;
473795 cc->lower_ = lower_;
473796 cc->nrunes_ = nrunes_;
473797 return cc;
473798}

◆ AddCharClass()

void duckdb_re2::CharClassBuilder::AddCharClass ( CharClassBuilder * cc)
473776 {
473777 for (iterator it = cc->begin(); it != cc->end(); ++it)
473778 AddRange(it->lo, it->hi);
473779}

◆ Negate()

void duckdb_re2::CharClassBuilder::Negate ( )
473836 {
473837 // Build up negation and then copy in.
473838 // Could edit ranges in place, but C++ won't let me.
473839 std::vector<RuneRange> v;
473840 v.reserve(ranges_.size() + 1);
473841
473842 // In negation, first range begins at 0, unless
473843 // the current class begins at 0.
473844 iterator it = begin();
473845 if (it == end()) {
473846 v.push_back(RuneRange(0, Runemax));
473847 } else {
473848 int nextlo = 0;
473849 if (it->lo == 0) {
473850 nextlo = it->hi + 1;
473851 ++it;
473852 }
473853 for (; it != end(); ++it) {
473854 v.push_back(RuneRange(nextlo, it->lo - 1));
473855 nextlo = it->hi + 1;
473856 }
473857 if (nextlo <= Runemax)
473858 v.push_back(RuneRange(nextlo, Runemax));
473859 }
473860
473861 ranges_.clear();
473862 for (size_t i = 0; i < v.size(); i++)
473863 ranges_.insert(v[i]);
473864
473865 upper_ = AlphaMask & ~upper_;
473866 lower_ = AlphaMask & ~lower_;
473867 nrunes_ = Runemax+1 - nrunes_;
473868}
uint32_t v

◆ RemoveAbove()

void duckdb_re2::CharClassBuilder::RemoveAbove ( Rune r)
473802 {
473803 if (r >= Runemax)
473804 return;
473805
473806 if (r < 'z') {
473807 if (r < 'a')
473808 lower_ = 0;
473809 else
473810 lower_ &= AlphaMask >> ('z' - r);
473811 }
473812
473813 if (r < 'Z') {
473814 if (r < 'A')
473815 upper_ = 0;
473816 else
473817 upper_ &= AlphaMask >> ('Z' - r);
473818 }
473819
473820 for (;;) {
473821
473822 iterator it = ranges_.find(RuneRange(r + 1, Runemax));
473823 if (it == end())
473824 break;
473825 RuneRange rr = *it;
473826 ranges_.erase(it);
473827 nrunes_ -= rr.hi - rr.lo + 1;
473828 if (rr.lo <= r) {
473829 rr.hi = r;
473830 ranges_.insert(rr);
473831 nrunes_ += rr.hi - rr.lo + 1;
473832 }
473833 }
473834}

◆ GetCharClass()

CharClass * duckdb_re2::CharClassBuilder::GetCharClass ( )
473927 {
473928 CharClass* cc = CharClass::New(ranges_.size());
473929 int n = 0;
473930 for (iterator it = begin(); it != end(); ++it)
473931 cc->ranges_[n++] = *it;
473932 cc->nranges_ = n;
473933 DCHECK_LE(n, static_cast<int>(ranges_.size()));
473934 cc->nrunes_ = nrunes_;
473935 cc->folds_ascii_ = FoldsASCII();
473936 return cc;
473937}

◆ AddRangeFlags()

void duckdb_re2::CharClassBuilder::AddRangeFlags ( Rune lo,
Rune hi,
Regexp::ParseFlags parse_flags )
468270 {
468271
468272 // Take out \n if the flags say so.
468273 bool cutnl = !(parse_flags & Regexp::ClassNL) ||
468274 (parse_flags & Regexp::NeverNL);
468275 if (cutnl && lo <= '\n' && '\n' <= hi) {
468276 if (lo < '\n')
468277 AddRangeFlags(lo, '\n' - 1, parse_flags);
468278 if (hi > '\n')
468279 AddRangeFlags('\n' + 1, hi, parse_flags);
468280 return;
468281 }
468282
468283 // If folding case, add fold-equivalent characters too.
468284 if (parse_flags & Regexp::FoldCase)
468285 AddFoldedRange(this, lo, hi, 0);
468286 else
468287 AddRange(lo, hi);
468288}

The documentation for this class was generated from the following file: