bool parameters::then_else( bool expr, value_type const &s, value_type::size_type *pos, value_type *replacement ) const { value_type::value_type c = s[ *pos ]; bool found_param = false, not_empty = false; switch ( c ) { case_123456789: found_param = true; if ( expr ) { *replacement = lookup_param( to_index( c ) ); not_empty = !replacement->empty(); } break; case '{': while ( ++*pos < s.size() ) { c = s[ *pos ]; switch ( c ) { case_123456789: found_param = true; if ( expr ) { value_type const param = lookup_param( to_index( c ) ); not_empty = !param.empty() || not_empty; *replacement += param; } break; case '}': goto done; case '\\': if ( *pos + 1 < s.size() ) c = s[ ++*pos ]; // no break; default: if ( expr ) *replacement += c; } // switch } // while throw invalid_argument( "'}' expected for ?:" ); default: throw invalid_argument( BUILD_STRING( '\'', c, "': invalid character after '", (expr ? '?' : ':'), "' (one of [1-9{] expected)" ) ); } // switch done: return !found_param || not_empty; }
//! The function performs formatting of the extracted scope stack in reverse direction void format_reverse(stream_type& strm, value_type const& scopes) const { value_type::const_reverse_iterator it = scopes.rbegin(), end; if (m_depth > 0) { value_type::size_type const scopes_to_iterate = (std::min)(m_depth, scopes.size()); end = it; std::advance(end, static_cast< value_type::difference_type >(scopes_to_iterate)); } else { end = scopes.rend(); } if (it != end) { m_element_formatter(strm, *it); for (++it; it != end; ++it) { strm << m_delimiter; m_element_formatter(strm, *it); } if (it != scopes.rend()) strm << m_incomplete_marker; } }
//! The function performs formatting of the extracted scope stack in forward direction void format_forward(stream_type& strm, value_type const& scopes) const { value_type::const_iterator it, end = scopes.end(); if (m_depth > 0) { value_type::size_type const scopes_to_iterate = (std::min)(m_depth, scopes.size()); it = scopes.end(); std::advance(it, -static_cast< value_type::difference_type >(scopes_to_iterate)); } else { it = scopes.begin(); } if (it != end) { if (it != scopes.begin()) strm << "..." << m_delimiter; m_element_formatter(strm, *it); for (++it; it != end; ++it) { strm << m_delimiter; m_element_formatter(strm, *it); } } }
static void bind( sqlite3_stmt* statement_handle, std::size_t index, value_type value ) { sqlite3_bind_blob( statement_handle, index , value.bytes(), value.size(), SQLITE_TRANSIENT ); }
hex_pair_iterator operator ++() { // We're at the end of the input. if (Current == End) { IsDone = true; return *this; } Pair = value_type(); for (; Current != End && Pair.size() != 2; ++Current) { // Is a valid hex digit. if ((*Current >= '0' && *Current <= '9') || (*Current >= 'a' && *Current <= 'f') || (*Current >= 'A' && *Current <= 'F')) Pair.push_back(*Current); } // Hit the end without getting 2 hex digits. Pair is invalid. if (Pair.size() != 2) IsDone = true; return *this; }
void unc_text::set(const value_type& data, int idx, int len) { fix_len_idx(data.size(), idx, len); m_chars.resize(len); int di = 0; while (len-- > 0) { m_chars[di++] = data[idx++]; } m_logok = false; }
void unc_text::set(const value_type &data, size_t idx, size_t len) { m_chars.resize(len); len = fix_len_idx(data.size(), idx, len); for (size_t di = 0; len > 0; di++, idx++, len--) { m_chars[di] = data[idx]; } update_logtext(); }
GLuint GetEarliestIndex(value_type const &key, GLuint curIndex) { union { float F; GLuint H; } U; GLuint hash = OFFSET; for (std::size_t i = 0; i < key.size(); ++i) { U.F = key[i]; hash ^= U.H; hash *= PRIME; } // Maintain key/hash state invariant. GLuint killIndex = curIndex % mDepth; mHash[killIndex] = hash; mAttr[killIndex] = key; mIndex[killIndex] = curIndex; // Starting at the further index from ours, // try to find a copy of our value. for (GLuint i = 1; i <= mDepth; ++i) { GLuint lookIndex = (killIndex + i) % mDepth; if ((mHash[lookIndex] == hash) && (mAttr[lookIndex] == key)) { if (i < mDepth) ++mHits; else ++mMisses; return mIndex[lookIndex]; } } assert(false && "This is unreachable."); return 0; }
static int count(value_type const& i) { return static_cast<int>(i.size()); }
/** Returns the payload size of the body When this body is used with @ref message::prepare_payload, the Content-Length will be set to the payload size, and any chunked Transfer-Encoding will be removed. */ static std::uint64_t size(value_type const& v) { return v.size(); }
/** Returns the payload size of the body When this body is used with @ref message::prepare_payload, the Content-Length will be set to the payload size, and any chunked Transfer-Encoding will be removed. */ static std::uint64_t size(value_type const& body) { return body.size(); }
size_t size() const { return oneLineNotation.size(); }
static std::size_t encodedLength(value_type const& value) { return value.size(); }
measured_type operator()(value_type p) const { measured_type m = algebra_type::identity(); m.value1 = p->size(); m.value2 = p->get_cached(); return m; }