本文整理汇总了C++中icompare函数的典型用法代码示例。如果您正苦于以下问题:C++ icompare函数的具体用法?C++ icompare怎么用?C++ icompare使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了icompare函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTransferEncoding
void HTTPMessage::setTransferEncoding(const std::string& transferEncoding)
{
if (icompare(transferEncoding, IDENTITY_TRANSFER_ENCODING) == 0)
erase(TRANSFER_ENCODING);
else
set(TRANSFER_ENCODING, transferEncoding);
}
示例2: icompare
int icompare(const std::string& str1, std::string::size_type pos1, std::string::size_type n, const std::string& str2, std::string::size_type pos2)
{
std::string::size_type sz2 = str2.size();
if (pos2 > sz2) pos2 = sz2;
if (pos2 + n > sz2) n = sz2 - pos2;
return icompare(str1, pos1, n, str2.begin() + pos2, str2.begin() + pos2 + n);
}
示例3: icompare
int UTF8::icompare(const std::string& str1, std::string::size_type pos1, std::string::size_type n1, const std::string& str2, std::string::size_type pos2, std::string::size_type n2)
{
std::string::size_type sz2 = str2.size();
if (pos2 > sz2) pos2 = sz2;
if (pos2 + n2 > sz2) n2 = sz2 - pos2;
return icompare(str1, pos1, n1, str2.begin() + pos2, str2.begin() + pos2 + n2);
}
示例4: while
void IniFileConfigurationNew::removeRaw(const std::string& key)
{
std::string prefix = key;
if (!prefix.empty()) prefix += '.';
std::string::size_type psize = prefix.size();
IStringMap::iterator it = _map.begin();
IStringMap::iterator itCur;
while (it != _map.end())
{
itCur = it++;
if ((icompare(itCur->first, key) == 0) || (icompare(itCur->first, psize, prefix) == 0))
{
_map.erase(itCur);
}
}
}
示例5: get
bool HTTPMessage::getKeepAlive() const
{
const std::string& connection = get(CONNECTION, EMPTY);
if (!connection.empty())
return icompare(connection, CONNECTION_CLOSE) != 0;
else
return getVersion() == HTTP_1_1;
}
示例6: iEndsWith
bool iEndsWith(const std::string &str, const std::string &suffix) {
if (str.size() < suffix.size()) {
return false;
}
auto tstr = str.substr(str.size() - suffix.size());
return icompare(tstr, suffix) == 0;
}
示例7: _version
HTTPCookie::HTTPCookie(const NameValueCollection& nvc):
_version(0),
_secure(false),
_maxAge(-1),
_httpOnly(false)
{
for (NameValueCollection::ConstIterator it = nvc.begin(); it != nvc.end(); ++it)
{
const std::string& name = it->first;
const std::string& value = it->second;
if (icompare(name, "comment") == 0)
{
setComment(value);
}
else if (icompare(name, "domain") == 0)
{
setDomain(value);
}
else if (icompare(name, "path") == 0)
{
setPath(value);
}
else if (icompare(name, "max-age") == 0)
{
setMaxAge(NumberParser::parse(value));
}
else if (icompare(name, "secure") == 0)
{
setSecure(true);
}
else if (icompare(name, "expires") == 0)
{
int tzd;
DateTime exp = DateTimeParser::parse(value, tzd);
Timestamp now;
setMaxAge((int) ((exp.timestamp() - now) / Timestamp::resolution()));
}
else if (icompare(name, "version") == 0)
{
setVersion(NumberParser::parse(value));
}
else if (icompare(name, "HttpOnly") == 0)
{
setHttpOnly(true);
}
else
{
setName(name);
setValue(value);
}
}
}
示例8: setNoPurge
bool FileChannel::setNoPurge(const std::string& value)
{
if (value.empty() || 0 == icompare(value, "none"))
{
delete _pPurgeStrategy;
_pPurgeStrategy = 0;
_purgeAge = "none";
return true;
}
else return false;
}
示例9: icompare
WebSocketImpl* WebSocket::accept(HTTPServerRequest& request, HTTPServerResponse& response)
{
if (icompare(request.get("Connection", ""), "Upgrade") == 0 &&
icompare(request.get("Upgrade", ""), "websocket") == 0)
{
std::string version = request.get("Sec-WebSocket-Version", "");
if (version.empty()) throw WebSocketException("Missing Sec-WebSocket-Version in handshake request", WS_ERR_HANDSHAKE_NO_VERSION);
if (version != WEBSOCKET_VERSION) throw WebSocketException("Unsupported WebSocket version requested", version, WS_ERR_HANDSHAKE_UNSUPPORTED_VERSION);
std::string key = request.get("Sec-WebSocket-Key", "");
Poco::trimInPlace(key);
if (key.empty()) throw WebSocketException("Missing Sec-WebSocket-Key in handshake request", WS_ERR_HANDSHAKE_NO_KEY);
response.setStatusAndReason(HTTPResponse::HTTP_SWITCHING_PROTOCOLS);
response.set("Upgrade", "websocket");
response.set("Connection", "Upgrade");
response.set("Sec-WebSocket-Accept", computeAccept(key));
response.setContentLength(0);
response.send().flush();
return new WebSocketImpl(static_cast<StreamSocketImpl*>(static_cast<HTTPServerRequestImpl&>(request).detachSocket().impl()), false);
}
else throw WebSocketException("No WebSocket handshake", WS_ERR_NO_HANDSHAKE);
}
示例10: _version
HTTPCookie::HTTPCookie(const NameValueCollection& nvc):
_version(0),
_secure(false),
_maxAge(-1),
_httpOnly(false)
{
for (NameValueCollection::ConstIterator it = nvc.begin(); it != nvc.end(); ++it) {
const std::string& name = it->first;
const std::string& value = it->second;
if (icompare(name, "comment") == 0) {
setComment(value);
}
else if (icompare(name, "domain") == 0) {
setDomain(value);
}
else if (icompare(name, "path") == 0) {
setPath(value);
}
else if (icompare(name, "priority") == 0) {
setPriority(value);
}
else if (icompare(name, "max-age") == 0) {
throw NotImplementedException("HTTPCookie::HTTPCookie max-age");
}
else if (icompare(name, "secure") == 0) {
setSecure(true);
}
else if (icompare(name, "expires") == 0) {
throw NotImplementedException("HTTPCookie::HTTPCookie expires");
}
else if (icompare(name, "version") == 0) {
throw NotImplementedException("HTTPCookie::HTTPCookie version");
}
else if (icompare(name, "HttpOnly") == 0) {
setHttpOnly(true);
}
else {
setName(name);
setValue(value);
}
}
}
示例11: NotAuthenticatedException
void OAuth20Credentials::extractBearerToken(const HTTPRequest& request)
{
if (request.hasCredentials())
{
std::string authScheme;
std::string authInfo;
request.getCredentials(authScheme, authInfo);
if (icompare(authScheme, _scheme) == 0)
{
_bearerToken = authInfo;
}
else throw NotAuthenticatedException("No bearer token in Authorization header", authScheme);
}
else throw NotAuthenticatedException("No Authorization header found");
}
示例12: if
int Logger::parseLevel(const std::string& level)
{
if (icompare(level, "none") == 0)
return 0;
else if (icompare(level, "fatal") == 0)
return Message::PRIO_FATAL;
else if (icompare(level, "critical") == 0)
return Message::PRIO_CRITICAL;
else if (icompare(level, "error") == 0)
return Message::PRIO_ERROR;
else if (icompare(level, "warning") == 0)
return Message::PRIO_WARNING;
else if (icompare(level, "notice") == 0)
return Message::PRIO_NOTICE;
else if (icompare(level, "information") == 0)
return Message::PRIO_INFORMATION;
else if (icompare(level, "debug") == 0)
return Message::PRIO_DEBUG;
else if (icompare(level, "trace") == 0)
return Message::PRIO_TRACE;
else
throw InvalidArgumentException("Not a valid log level", level);
}
示例13: setPurgeAge
void FileChannel::setPurgeAge(const std::string& age)
{
delete _pPurgeStrategy;
_pPurgeStrategy = 0;
_purgeAge = "none";
if (age.empty() || 0 == icompare(age, "none"))
return;
std::string::const_iterator it = age.begin();
std::string::const_iterator end = age.end();
int n = 0;
while (it != end && Ascii::isSpace(*it))
++it;
while (it != end && Ascii::isDigit(*it))
{
n *= 10;
n += *it++ - '0';
}
while (it != end && Ascii::isSpace(*it))
++it;
std::string unit;
while (it != end && Ascii::isAlpha(*it))
unit += *it++;
Timespan::TimeDiff factor = Timespan::SECONDS;
if (unit == "minutes")
factor = Timespan::MINUTES;
else if (unit == "hours")
factor = Timespan::HOURS;
else if (unit == "days")
factor = Timespan::DAYS;
else if (unit == "weeks")
factor = 7*Timespan::DAYS;
else if (unit == "months")
factor = 30 * Timespan::DAYS;
else if (unit != "seconds")
throw InvalidArgumentException("purgeAge", age);
if (0 == n)
throw InvalidArgumentException("Zero is not valid purge age.");
_pPurgeStrategy = new PurgeByAgeStrategy(Timespan(factor * n));
_purgeAge = age;
}
示例14: icompare
void WindowsColorConsoleChannel::setProperty(const std::string& name, const std::string& value)
{
if (name == "enableColors")
{
_enableColors = icompare(value, "true") == 0;
}
else if (name == "traceColor")
{
_colors[Message::PRIO_TRACE] = parseColor(value);
}
else if (name == "debugColor")
{
_colors[Message::PRIO_DEBUG] = parseColor(value);
}
else if (name == "informationColor")
{
_colors[Message::PRIO_INFORMATION] = parseColor(value);
}
else if (name == "noticeColor")
{
_colors[Message::PRIO_NOTICE] = parseColor(value);
}
else if (name == "warningColor")
{
_colors[Message::PRIO_WARNING] = parseColor(value);
}
else if (name == "errorColor")
{
_colors[Message::PRIO_ERROR] = parseColor(value);
}
else if (name == "criticalColor")
{
_colors[Message::PRIO_CRITICAL] = parseColor(value);
}
else if (name == "fatalColor")
{
_colors[Message::PRIO_FATAL] = parseColor(value);
}
else
{
Channel::setProperty(name, value);
}
}
示例15: setLevel
void LevelFilterChannel::setLevel(const std::string& value)
{
if (icompare(value, "fatal") == 0)
setLevel(Message::PRIO_FATAL);
else if (icompare(value, "critical") == 0)
setLevel(Message::PRIO_CRITICAL);
else if (icompare(value, "error") == 0)
setLevel(Message::PRIO_ERROR);
else if (icompare(value, "warning") == 0)
setLevel(Message::PRIO_WARNING);
else if (icompare(value, "notice") == 0)
setLevel(Message::PRIO_NOTICE);
else if (icompare(value, "information") == 0)
setLevel(Message::PRIO_INFORMATION);
else if (icompare(value, "debug") == 0)
setLevel(Message::PRIO_DEBUG);
else if (icompare(value, "trace") == 0)
setLevel(Message::PRIO_TRACE);
else
throw InvalidArgumentException("Not a valid log value", value);
}