本文整理汇总了C++中exlib::string类的典型用法代码示例。如果您正苦于以下问题:C++ string类的具体用法?C++ string怎么用?C++ string使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了string类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: connect
result_t net_base::connect(exlib::string url, int32_t timeout, obj_ptr<Stream_base>& retVal,
AsyncEvent* ac)
{
if (!qstrcmp(url.c_str(), "ssl:", 4))
return ssl_base::connect(url, timeout, retVal, ac);
if (qstrcmp(url.c_str(), "tcp:", 4))
return CHECK_ERROR(CALL_E_INVALIDARG);
if (ac->isSync())
return CHECK_ERROR(CALL_E_NOSYNC);
obj_ptr<Url> u = new Url();
result_t hr = u->parse(url);
if (hr < 0)
return hr;
if (u->m_port.length() == 0)
return CHECK_ERROR(CALL_E_INVALIDARG);
int32_t nPort = atoi(u->m_port.c_str());
int32_t family = u->m_ipv6 ? net_base::_AF_INET6 : net_base::_AF_INET;
obj_ptr<Socket_base> socket;
hr = Socket_base::_new(family, net_base::_SOCK_STREAM, socket);
if (hr < 0)
return hr;
socket->set_timeout(timeout);
retVal = socket;
return socket->connect(u->m_hostname, nPort, ac);
}
开发者ID:asionius,项目名称:fibjs,代码行数:35,代码来源:net.cpp
示例2: parseCookie
result_t HttpCollection::parseCookie(exlib::string &str)
{
const char *pstr = str.c_str();
int32_t nSize = (int32_t) str.length();
const char *pstrTemp;
exlib::string strKey, strValue;
while (nSize)
{
while (nSize && *pstr == ' ')
{
pstr++;
nSize--;
}
pstrTemp = pstr;
while (nSize && *pstr != '=' && *pstr != ';')
{
pstr++;
nSize--;
}
if (pstr > pstrTemp)
Url::decodeURI(pstrTemp, (int32_t) (pstr - pstrTemp), strKey, true);
else
strKey.clear();
if (nSize && *pstr == '=')
{
nSize--;
pstr++;
}
pstrTemp = pstr;
while (nSize && *pstr != ';')
{
pstr++;
nSize--;
}
if (!strKey.empty())
{
if (pstr > pstrTemp)
Url::decodeURI(pstrTemp, (int32_t) (pstr - pstrTemp), strValue, true);
else
strValue.clear();
}
if (nSize)
{
nSize--;
pstr++;
}
if (!strKey.empty())
add(strKey, strValue);
}
return 0;
}
开发者ID:ngot,项目名称:fibjs,代码行数:60,代码来源:HttpCollection.cpp
示例3: CHECK_ERROR
result_t X509Cert::get_serial(exlib::string &retVal)
{
mbedtls_x509_crt *crt = get_crt();
if (!crt)
return CHECK_ERROR(CALL_E_INVALID_CALL);
int32_t ret;
mbedtls_mpi serial;
mbedtls_mpi_init(&serial);
ret = mbedtls_mpi_read_binary(&serial, crt->serial.p, crt->serial.len);
if (ret != 0)
return CHECK_ERROR(_ssl::setError(ret));
retVal.resize(8192);
size_t sz = retVal.length();
ret = mbedtls_mpi_write_string(&serial, 10, &retVal[0], sz, &sz);
mbedtls_mpi_free(&serial);
if (ret != 0)
return CHECK_ERROR(_ssl::setError(ret));
retVal.resize(sz - 1);
return 0;
}
开发者ID:anlebcoder,项目名称:fibjs,代码行数:26,代码来源:X509Cert.cpp
示例4: extname
result_t path_base::extname(exlib::string path, exlib::string &retVal)
{
char ch;
const char *p1 = NULL;
const char* c_str = path.c_str();
if (*c_str == '.')
c_str++;
while (*c_str)
{
ch = *c_str++;
if (isPathSlash(ch))
{
if (*c_str == '.')
c_str++;
p1 = NULL;
}
else if (ch == '.')
p1 = c_str - 1;
}
if (p1)
retVal.assign(p1, (int32_t) (c_str - p1));
return 0;
}
开发者ID:anlebcoder,项目名称:fibjs,代码行数:27,代码来源:path.cpp
示例5: parse
result_t XmlParser::parse(XmlDocument* doc, exlib::string source)
{
XmlParser parser(doc, true);
parser.m_now = doc;
parser.m_list.push_back(doc);
XML_Parser xml_parser = XML_ParserCreate(NULL);
XML_SetParamEntityParsing(xml_parser, XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE);
XML_SetUserData(xml_parser, &parser);
XML_SetXmlDeclHandler(xml_parser, XmlDeclHandler);
XML_SetElementHandler(xml_parser, StartElementHandler, EndElementHandler);
XML_SetCharacterDataHandler(xml_parser, CharacterDataHandler);
XML_SetProcessingInstructionHandler(xml_parser, ProcessingInstructionHandler);
XML_SetCommentHandler(xml_parser, CommentHandler);
XML_SetCdataSectionHandler(xml_parser, StartCdataSectionHandler, EndCdataSectionHandler);
XML_SetStartDoctypeDeclHandler(xml_parser, StartDoctypeDeclHandler);
if (XML_Parse(xml_parser, source.c_str(), (int32_t)source.length(), true) != XML_STATUS_OK) {
char msg[128];
sprintf(msg, "XmlParser: error on line %lu at column %lu: %s", XML_GetCurrentLineNumber(xml_parser),
XML_GetCurrentColumnNumber(xml_parser) + 1,
XML_ErrorString(XML_GetErrorCode(xml_parser)));
XML_ParserFree(xml_parser);
return CHECK_ERROR(Runtime::setError(msg));
}
XML_ParserFree(xml_parser);
return 0;
}
开发者ID:asionius,项目名称:fibjs,代码行数:34,代码来源:XmlParser.cpp
示例6: toString
result_t XmlComment::toString(exlib::string &retVal)
{
retVal = "<!--";
retVal.append(m_data.data());
retVal.append("-->");
return 0;
}
开发者ID:anlebcoder,项目名称:fibjs,代码行数:8,代码来源:XmlComment.cpp
示例7: get_search
result_t Url::get_search(exlib::string& retVal)
{
if (m_query.length() > 0) {
retVal.assign(1, '?');
retVal.append(m_query);
}
return 0;
}
开发者ID:asionius,项目名称:fibjs,代码行数:9,代码来源:Url.cpp
示例8: execute
result_t SQLite::execute(exlib::string sql, obj_ptr<DBResult_base> &retVal, AsyncEvent *ac)
{
if (!m_db)
return CHECK_ERROR(CALL_E_INVALID_CALL);
if (!ac)
return CHECK_ERROR(CALL_E_NOSYNC);
return execute(sql.c_str(), (int32_t) sql.length(), retVal);
}
开发者ID:ngot,项目名称:fibjs,代码行数:10,代码来源:SQLite.cpp
示例9: CHECK_ERROR
result_t X509Crl::load(exlib::string pemCrl)
{
int32_t ret;
ret = mbedtls_x509_crl_parse(&m_crl, (const unsigned char *)pemCrl.c_str(),
pemCrl.length() + 1);
if (ret != 0)
return CHECK_ERROR(_ssl::setError(ret));
return 0;
}
开发者ID:ngot,项目名称:fibjs,代码行数:11,代码来源:X509Crl.cpp
示例10: rename
result_t fs_base::rename(exlib::string from, exlib::string to,
AsyncEvent *ac)
{
if (!ac)
return CHECK_ERROR(CALL_E_NOSYNC);
if (::rename(from.c_str(), to.c_str()))
return CHECK_ERROR(LastError());
return 0;
}
开发者ID:anlebcoder,项目名称:fibjs,代码行数:11,代码来源:fs.cpp
示例11: dirname
result_t path_base::dirname(exlib::string path, exlib::string &retVal)
{
char ch;
const char* c_str = path.c_str();
const char *p1 = c_str;
const char *p2 = NULL;
#ifdef _WIN32
if (c_str[0] != 0 && c_str[1] == ':')
{
c_str += 2;
if (isPathSlash(*c_str))
c_str++;
p2 = c_str;
}
else if (isPathSlash(c_str[0]) && isPathSlash(c_str[1]))
{
c_str += 2;
while (*c_str && !isPathSlash(*c_str))
c_str++;
if (*c_str)
{
c_str++;
while (*c_str && !isPathSlash(*c_str))
c_str++;
if (*c_str)
c_str++;
}
p2 = c_str;
}
#endif
while (*c_str)
{
ch = *c_str++;
if (isPathSlash(ch) && *c_str)
p2 = c_str - 1;
}
if (p2 == NULL)
p2 = p1;
if (isPathSlash(*p2) && p2 == p1)
p2++;
retVal.assign(p1, (int32_t) (p2 - p1));
return 0;
}
开发者ID:anlebcoder,项目名称:fibjs,代码行数:53,代码来源:path.cpp
示例12: get_href
result_t Url::get_href(exlib::string& retVal)
{
retVal.clear();
if (m_protocol.length() > 0)
retVal.append(m_protocol);
if (m_slashes)
retVal.append("//", 2);
exlib::string str;
if (m_username.length() > 0) {
get_auth(str);
retVal.append(str);
retVal.append(1, '@');
}
get_host(str);
retVal.append(str);
get_path(str);
retVal.append(str);
retVal.append(m_hash);
return 0;
}
开发者ID:asionius,项目名称:fibjs,代码行数:28,代码来源:Url.cpp
示例13: get_auth
result_t Url::get_auth(exlib::string& retVal)
{
exlib::string str;
encoding_base::encodeURIComponent(m_username, str);
retVal = str;
if (m_password.length() > 0) {
retVal.append(1, ':');
encoding_base::encodeURIComponent(m_password, str);
retVal.append(str);
}
return 0;
}
开发者ID:asionius,项目名称:fibjs,代码行数:14,代码来源:Url.cpp
示例14: parse
result_t querystring_base::parse(exlib::string str, exlib::string sep,
exlib::string eq, v8::Local<v8::Object> opt,
obj_ptr<HttpCollection_base>& retVal)
{
result_t hr;
obj_ptr<HttpCollection> c = new HttpCollection();
hr = c->parse(str, sep.c_str(), eq.c_str());
if (hr < 0)
return hr;
retVal = c;
return 0;
}
开发者ID:asionius,项目名称:fibjs,代码行数:15,代码来源:querystring.cpp
示例15: strchr
result_t net_base::isIPv6(exlib::string ip, bool& retVal)
{
result_t hr;
retVal = true;
const char* src = ip.c_str();
int len;
char tmp[INET6_ADDRSTRLEN], *s, *p;
unsigned char dst[sizeof(struct in6_addr)];
s = (char*)src;
p = strchr(s, '%');
if (p != NULL) {
s = tmp;
len = (int32_t)(p - src);
if (len > INET6_ADDRSTRLEN - 1) {
retVal = false;
return 0;
}
memcpy(s, src, len);
s[len] = '\0';
}
hr = inet_pton6(s, dst);
if (hr != 0)
retVal = false;
return 0;
}
开发者ID:asionius,项目名称:fibjs,代码行数:26,代码来源:net.cpp
示例16: resolve
result_t dns_base::resolve(exlib::string name, obj_ptr<NArray>& retVal, AsyncEvent* ac)
{
if (ac->isSync())
return CHECK_ERROR(CALL_E_LONGSYNC);
addrinfo hints = { 0, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, 0, 0, 0, 0 };
addrinfo* result = NULL;
addrinfo* ptr = NULL;
int res = getaddrinfo(name.c_str(), NULL, &hints, &result);
if (res)
return CHECK_ERROR(Runtime::setError(gai_strerror(res)));
obj_ptr<NArray> arr = new NArray();
for (ptr = result; ptr != NULL; ptr = ptr->ai_next) {
inetAddr addr_info;
addr_info.init(ptr->ai_addr);
arr->append(addr_info.str());
}
freeaddrinfo(result);
retVal = arr;
return 0;
}
开发者ID:asionius,项目名称:fibjs,代码行数:26,代码来源:net.cpp
示例17: readTextFile
result_t fs_base::readTextFile(exlib::string fname, exlib::string& retVal,
AsyncEvent* ac)
{
if (ac->isSync())
return CHECK_ERROR(CALL_E_NOSYNC);
obj_ptr<SeekableStream_base> f;
obj_ptr<Buffer_base> buf;
result_t hr;
hr = openFile(fname, "r", f, ac);
if (hr < 0)
return hr;
hr = f->cc_readAll(buf);
f->cc_close();
if (hr == CALL_RETURN_NULL) {
retVal.clear();
return 0;
}
if (hr < 0)
return hr;
return buf->toString(retVal);
}
开发者ID:asionius,项目名称:fibjs,代码行数:27,代码来源:fs.cpp
示例18: msgMethod
inline result_t msgMethod(Message_base *msg, exlib::string &method)
{
exlib::string str;
const char *p, *p1;
msg->get_value(str);
p = p1 = str.c_str();
while (true)
{
while (*p && *p != '.' && *p != '/' && *p != '\\')
p++;
if (p != p1)
break;
if (!*p)
return CHECK_ERROR(Runtime::setError("JSHandler: method \"" + method + "\" not found."));
p++;
p1 = p;
}
msg->set_value(*p ? p + 1 : "");
method.assign(p1, (int32_t) (p - p1));
return 0;
}
开发者ID:ngot,项目名称:fibjs,代码行数:25,代码来源:JSHandler.cpp
示例19: set_id
result_t XmlElement::set_id(exlib::string newVal)
{
if (newVal.empty())
return removeAttribute("id");
return setAttribute("id", newVal);
}
开发者ID:lx6317648,项目名称:fibjs,代码行数:7,代码来源:XmlElement.cpp
示例20: utf8to16String
result_t path_base::fullpath(exlib::string path, exlib::string &retVal)
{
#ifdef _WIN32
exlib::wstring str = utf8to16String(path);
exlib::wchar utf16_buffer[MAX_PATH];
DWORD utf16_len = GetFullPathNameW(str.c_str(), MAX_PATH, utf16_buffer, NULL);
if (!utf16_len)
return CHECK_ERROR(LastError());
retVal = utf16to8String(utf16_buffer, (int32_t)utf16_len);
return 0;
#else
if (isPathSlash(path.c_str()[0]))
return normalize(path, retVal);
exlib::string str;
process_base::cwd(str);
str.append(1, PATH_SLASH);
str.append(path);
return normalize(str, retVal);
#endif
}
开发者ID:anlebcoder,项目名称:fibjs,代码行数:25,代码来源:path.cpp
注:本文中的exlib::string类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论