/** \brief Create a virtual seeker. * * This constructor defines a virtual seeker start and end offsets * on initialization. By default it is initialized to a transparent * seeker since the start and end are set to zero. * * \note * If the offsets are left undefined (both set to zero) then the virtual * seeker is viewed as a transparent seeker, meaning that it seeks in * the input streams as if it did not exist. * * \warning * The virtual seek end offset is quite peculiar in that it is defined * as a POSITIVE number from the end of the file, going backward. The * normal seekg() command expects a negative number of an offset to be * applied from the end of the file. * * \warning * The class is not attached to one specific input stream so there is no * way to verify that the offsets are valid (i.e. not representing an * empty virtual file or having offsets completely outside of the available * range.) * * \exception InvalidException * The two offsets must be positive. * * \param[in] start_offset The start offset of the embedded file. * \param[in] end_offset The end offset of the embedded file. */ VirtualSeeker::VirtualSeeker(offset_t start_offset, offset_t end_offset) : m_start_offset(start_offset) , m_end_offset(end_offset) { if(m_start_offset < 0 || m_end_offset < 0) { throw InvalidException("VirtualSeeker::VirtualSeeker(): the start and end offsets cannot be negative."); } }
Regex::Result Regex::match(const char * str, bool copyStr, std::size_t count) const { if (freed) throw InvalidException(); auto maxMatches = exp.re_nsub + 1; auto size = count < maxMatches ? count : maxMatches; Result ret(str, copyStr, size); ret.matched = regexec(&exp, str, size, ret.matches.data(), 0) == 0; return ret; }
/** \brief Set the offsets of the virtual seeker. * * This function can be used to change the virtual seeker offsets. * * \exception InvalidException * The start offset must be before or equal to the end offset or * this exception is raised. * * \param[in] start_offset The new start offset. * \param[in] end_offset The new end offset. */ void VirtualSeeker::setOffsets(offset_t start_offset, offset_t end_offset) { if(start_offset < 0 || end_offset < 0) { throw InvalidException("VirtualSeeker::VirtualSeeker(): the start and end offsets cannot be negative."); } m_start_offset = start_offset; m_end_offset = end_offset; }