本文整理汇总了C++中tiny_string类的典型用法代码示例。如果您正苦于以下问题:C++ tiny_string类的具体用法?C++ tiny_string怎么用?C++ tiny_string使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了tiny_string类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: strcasecmp
/* like strcasecmp(s1.raw_buf(),s2.raw_buf()) but for unicode
* TODO: slow! */
int tiny_string::strcasecmp(tiny_string& s2) const
{
char* str1 = g_utf8_casefold(this->raw_buf(),this->numBytes());
char* str2 = g_utf8_casefold(s2.raw_buf(),s2.numBytes());
int ret = g_utf8_collate(str1,str2);
g_free(str1);
g_free(str2);
return ret;
}
开发者ID:jobermayr,项目名称:lightspark,代码行数:11,代码来源:tiny_string.cpp
示例2: find
/* start is an index of characters.
* returns index of character */
uint32_t tiny_string::find(const tiny_string& needle, uint32_t start) const
{
//TODO: omit copy into std::string
size_t bytestart = g_utf8_offset_to_pointer(buf,start) - buf;
size_t bytepos = std::string(*this).find(needle.raw_buf(),bytestart,needle.numBytes());
if(bytepos == std::string::npos)
return npos;
else
return g_utf8_pointer_to_offset(buf,buf+bytepos);
}
开发者ID:jobermayr,项目名称:lightspark,代码行数:12,代码来源:tiny_string.cpp
示例3: call_toJSON
tiny_string Vector::toJSON(std::vector<ASObject *> &path, IFunction *replacer, const tiny_string &spaces, const tiny_string &filter)
{
bool ok;
tiny_string res = call_toJSON(ok,path,replacer,spaces,filter);
if (ok)
return res;
// check for cylic reference
if (std::find(path.begin(),path.end(), this) != path.end())
throwError<TypeError>(kJSONCyclicStructure);
path.push_back(this);
res += "[";
bool bfirst = true;
tiny_string newline = (spaces.empty() ? "" : "\n");
for (unsigned int i =0; i < vec.size(); i++)
{
tiny_string subres;
ASObject* o = vec[i];
if (!o)
o = getSystemState()->getNullRef();
if (replacer != NULL)
{
ASObject* params[2];
params[0] = abstract_di(getSystemState(),i);
params[0]->incRef();
params[1] = o;
params[1]->incRef();
ASObject *funcret=replacer->call(getSystemState()->getNullRef(), params, 2);
if (funcret)
subres = funcret->toJSON(path,NULL,spaces,filter);
}
else
{
subres = o->toJSON(path,replacer,spaces,filter);
}
if (!subres.empty())
{
if (!bfirst)
res += ",";
res += newline+spaces;
bfirst = false;
res += subres;
}
}
if (!bfirst)
res += newline+spaces.substr_bytes(0,spaces.numBytes()/2);
res += "]";
path.pop_back();
return res;
}
开发者ID:jobermayr,项目名称:lightspark,代码行数:52,代码来源:Vector.cpp
示例4: assert_and_throw
const tiny_string multiname::qualifiedString(SystemState* sys) const
{
assert_and_throw(ns.size()>=1);
assert_and_throw(name_type==NAME_STRING);
const tiny_string nsName=sys->getStringFromUniqueId(ns[0].nsNameId);
const tiny_string& name=sys->getStringFromUniqueId(name_s_id);
if(nsName.empty())
return name;
else
{
tiny_string ret=nsName;
ret+="::";
ret+=name;
return ret;
}
}
开发者ID:jobermayr,项目名称:lightspark,代码行数:16,代码来源:swftypes.cpp
示例5: parseNumber
int JSON::parseNumber(const tiny_string &jsonstring, int pos, ASObject** parent, const multiname& key)
{
int len = jsonstring.numBytes();
tiny_string res;
bool done = false;
while (!done && pos < len)
{
char c = jsonstring.charAt(pos);
switch(c)
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '-':
case '+':
case '.':
case 'E':
case 'e':
res += c;
pos++;
break;
default:
done = true;
break;
}
}
ASString* numstr = Class<ASString>::getInstanceS(res);
number_t num = numstr->toNumber();
if (std::isnan(num))
throwError<SyntaxError>(kJSONInvalidParseInput);
if (*parent == NULL)
*parent = Class<Number>::getInstanceS(num);
else
{
(*parent)->setVariableByMultiname(key,Class<Number>::getInstanceS(num),ASObject::CONST_NOT_ALLOWED);
}
return pos;
}
开发者ID:netroby,项目名称:lightspark,代码行数:47,代码来源:JSON.cpp
示例6: parseArray
int JSON::parseArray(const tiny_string &jsonstring, int pos, ASObject** parent, const multiname& key, IFunction *reviver)
{
int len = jsonstring.numChars();
pos++; // ignore '['
ASObject* subobj = Class<Array>::getInstanceS();
if (*parent == NULL)
*parent = subobj;
else
(*parent)->setVariableByMultiname(key,subobj,ASObject::CONST_NOT_ALLOWED);
multiname name(NULL);
name.name_type=multiname::NAME_INT;
name.name_i = 0;
name.ns.push_back(nsNameAndKind("",NAMESPACE));
name.isAttribute = false;
bool done = false;
bool needdata = false;
while (!done && pos < len)
{
while (jsonstring.charAt(pos) == ' ' ||
jsonstring.charAt(pos) == '\t' ||
jsonstring.charAt(pos) == '\n' ||
jsonstring.charAt(pos) == '\r'
)
pos++;
char c = jsonstring.charAt(pos);
switch(c)
{
case ']':
done = true;
pos++;
break;
case ',':
name.name_i++;
needdata = true;
pos++;
break;
default:
pos = parse(jsonstring,pos,&subobj,name, reviver);
needdata = false;
break;
}
}
if (!done || needdata)
throwError<SyntaxError>(kJSONInvalidParseInput);
return pos;
}
开发者ID:netroby,项目名称:lightspark,代码行数:47,代码来源:JSON.cpp
示例7: parseAll
void JSON::parseAll(const tiny_string &jsonstring, ASObject** parent , const multiname& key, IFunction *reviver)
{
int len = jsonstring.numBytes();
int pos = 0;
while (pos < len)
{
if (*parent && (*parent)->isPrimitive())
throwError<SyntaxError>(kJSONInvalidParseInput);
pos = parse(jsonstring, pos, parent , key, reviver);
while (jsonstring.charAt(pos) == ' ' ||
jsonstring.charAt(pos) == '\t' ||
jsonstring.charAt(pos) == '\n' ||
jsonstring.charAt(pos) == '\r'
)
pos++;
}
}
开发者ID:netroby,项目名称:lightspark,代码行数:17,代码来源:JSON.cpp
示例8: XMLNode
XMLDocument::XMLDocument(Class_base* c, tiny_string s)
: XMLNode(c),rootNode(NULL),ignoreWhite(false)
{
if(!s.empty())
{
parseXMLImpl(s);
}
}
开发者ID:ekapujiw2002,项目名称:lightspark,代码行数:8,代码来源:flashxml.cpp
示例9: isValidQName
bool Array::isValidQName(const tiny_string& name, const tiny_string& ns, unsigned int& index)
{
if(ns!="")
return false;
assert_and_throw(!name.empty());
index=0;
//First we try to convert the string name to an index, at the first non-digit
//we bail out
for(auto i=name.begin(); i!=name.end(); ++i)
{
if(!i.isdigit())
return false;
index*=10;
index+=i.digit_value();
}
return true;
}
开发者ID:lfjfrankie,项目名称:lightspark,代码行数:18,代码来源:Array.cpp
示例10: isIntegerWithoutLeadingZeros
bool Array::isIntegerWithoutLeadingZeros(const tiny_string& value)
{
if (value.empty())
return false;
else if (value == "0")
return true;
bool first = true;
for (CharIterator it=value.begin(); it!=value.end(); ++it)
{
if (!it.isdigit() || (first && *it == '0'))
return false;
first = false;
}
return true;
}
开发者ID:lfjfrankie,项目名称:lightspark,代码行数:18,代码来源:Array.cpp
示例11:
CurlDownloader::CurlDownloader(const tiny_string& u)
{
//TODO: Url encode the string
std::string tmp2;
tmp2.reserve(u.len()*2);
for(int i=0;i<u.len();i++)
{
if(u[i]==' ')
{
char buf[4];
sprintf(buf,"%%%x",(unsigned char)u[i]);
tmp2+=buf;
}
else
tmp2.push_back(u[i]);
}
url=tmp2;
}
开发者ID:stagenex,项目名称:lightspark,代码行数:18,代码来源:netutils.cpp
示例12: isValidQName
bool Array::isValidQName(const tiny_string& name, const tiny_string& ns, unsigned int& index)
{
if(ns!="")
return false;
assert_and_throw(name.len()!=0);
index=0;
//First we try to convert the string name to an index, at the first non-digit
//we bail out
for(int i=0;i<name.len();i++)
{
if(!isdigit(name[i]))
return false;
index*=10;
index+=(name[i]-'0');
}
return true;
}
开发者ID:stagenex,项目名称:lightspark,代码行数:18,代码来源:asobjects.cpp
示例13: openLink
void nsPluginInstance::openLink(const tiny_string& url, const tiny_string& window)
{
assert(!window.empty());
linkOpenData *data = new linkOpenData;
data->instance = mInstance;
data->url = url;
data->window = window;
NPN_PluginThreadAsyncCall(mInstance, asyncOpenPage, data);
}
开发者ID:ViciousPotato,项目名称:lightspark,代码行数:10,代码来源:plugin.cpp
示例14: connect
void XMLSocket::connect(tiny_string host, int port)
{
if (port <= 0 || port > 65535)
throw Class<SecurityError>::getInstanceS(getSystemState(),"Invalid port");
if (host.empty())
host = getSys()->mainClip->getOrigin().getHostname();
if (isConnected())
throw Class<IOError>::getInstanceS(getSystemState(),"Already connected");
// Host shouldn't contain scheme or port
if (host.strchr(':') != NULL)
throw Class<SecurityError>::getInstanceS(getSystemState(),"Invalid hostname");
// Check sandbox and policy file
size_t buflen = host.numBytes() + 22;
char *urlbuf = g_newa(char, buflen);
snprintf(urlbuf, buflen, "xmlsocket://%s:%d", host.raw_buf(), port);
URLInfo url(urlbuf);
getSystemState()->securityManager->checkURLStaticAndThrow(url,
~(SecurityManager::LOCAL_WITH_FILE),
SecurityManager::LOCAL_WITH_FILE | SecurityManager::LOCAL_TRUSTED,
true);
SecurityManager::EVALUATIONRESULT evaluationResult;
evaluationResult = getSys()->securityManager->evaluateSocketConnection(url, true);
if(evaluationResult != SecurityManager::ALLOWED)
{
incRef();
getVm(getSystemState())->addEvent(_MR(this), _MR(Class<SecurityErrorEvent>::getInstanceS(getSystemState(),"No policy file allows socket connection")));
return;
}
incRef();
XMLSocketThread *thread = new XMLSocketThread(_MR(this), host, port, timeout);
getSys()->addJob(thread);
job = thread;
}
开发者ID:jobermayr,项目名称:lightspark,代码行数:40,代码来源:XMLSocket.cpp
示例15: removeWhitespace
tiny_string XMLBase::removeWhitespace(tiny_string val)
{
bool bwhite = true;
uint32_t start = 0;
CharIterator it = val.begin();
CharIterator itend = val.begin();
while (it != val.end())
{
if (!g_unichar_isspace(*it))
{
itend=it;
itend++;
bwhite = false;
}
else if (bwhite)
start++;
it++;
}
if (bwhite)
return "";
return val.substr(start,itend);
}
开发者ID:lightspark,项目名称:lightspark,代码行数:22,代码来源:xml_support.cpp
示例16: encodeToXML
const tiny_string XMLBase::encodeToXML(const tiny_string value, bool bIsAttribute)
{
tiny_string res;
auto it = value.begin();
while (it != value.end())
{
switch (*it)
{
case '<':
res += "<";
break;
case '>':
res += bIsAttribute ? ">" : ">";
break;
case '&':
res += "&";
break;
case '\"':
res += bIsAttribute ? """ : "\"";
break;
case '\r':
res += bIsAttribute ? "
" : "\r";
break;
case '\n':
res += bIsAttribute ? "
" : "\n";
break;
case '\t':
res += bIsAttribute ? "	" : "\t";
break;
default:
res += *it;
break;
}
it++;
}
return res;
}
开发者ID:lightspark,项目名称:lightspark,代码行数:38,代码来源:xml_support.cpp
示例17: parseNull
int JSON::parseNull(const tiny_string &jsonstring, int pos,ASObject** parent,const multiname& key)
{
int len = jsonstring.numBytes();
if (len >= pos+4)
{
if (jsonstring.charAt(pos) == 'n' &&
jsonstring.charAt(pos + 1) == 'u' &&
jsonstring.charAt(pos + 2) == 'l' &&
jsonstring.charAt(pos + 3) == 'l')
{
pos += 4;
if (*parent == NULL)
*parent = getSys()->getNullRef();
else
(*parent)->setVariableByMultiname(key,getSys()->getNullRef(),ASObject::CONST_NOT_ALLOWED);
}
else
throwError<SyntaxError>(kJSONInvalidParseInput);
}
else
throwError<SyntaxError>(kJSONInvalidParseInput);
return pos;
}
开发者ID:netroby,项目名称:lightspark,代码行数:23,代码来源:JSON.cpp
示例18: parseTrue
int JSON::parseTrue(const tiny_string &jsonstring, int pos,ASObject** parent,const multiname& key)
{
int len = jsonstring.numBytes();
if (len >= pos+4)
{
if (jsonstring.charAt(pos) == 't' &&
jsonstring.charAt(pos + 1) == 'r' &&
jsonstring.charAt(pos + 2) == 'u' &&
jsonstring.charAt(pos + 3) == 'e')
{
pos += 4;
if (*parent == NULL)
*parent = abstract_b(true);
else
(*parent)->setVariableByMultiname(key,abstract_b(true),ASObject::CONST_NOT_ALLOWED);
}
else
throwError<SyntaxError>(kJSONInvalidParseInput);
}
else
throwError<SyntaxError>(kJSONInvalidParseInput);
return pos;
}
开发者ID:netroby,项目名称:lightspark,代码行数:23,代码来源:JSON.cpp
示例19: memset
bool SocketIO::connect(const tiny_string& hostname, int port)
{
struct addrinfo hints;
struct addrinfo *servinfo;
struct addrinfo *p;
if (fd != -1)
return false;
fd = -1;
if (port <= 0 || port > 65535)
return false;
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
tiny_string portstr = Integer::toString(port);
if (getaddrinfo(hostname.raw_buf(), portstr.raw_buf(), &hints, &servinfo) != 0)
{
return false;
}
for(p = servinfo; p != NULL; p = p->ai_next)
{
if ((fd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1)
continue;
// TODO: timeout on connect
if (::connect(fd, p->ai_addr, p->ai_addrlen) == -1)
{
::close(fd);
continue;
}
break;
}
freeaddrinfo(servinfo);
if (!p)
fd = -1;
return fd != -1;
}
开发者ID:jobermayr,项目名称:lightspark,代码行数:46,代码来源:XMLSocket.cpp
示例20: writeUTF
void ByteArray::writeUTF(const tiny_string& str)
{
getBuffer(position+str.numBytes()+2,true);
if(str.numBytes() > 65535)
{
throwError<RangeError>(kParamRangeError);
}
uint16_t numBytes=endianIn((uint16_t)str.numBytes());
memcpy(bytes+position,&numBytes,2);
memcpy(bytes+position+2,str.raw_buf(),str.numBytes());
position+=str.numBytes()+2;
}
开发者ID:DanyPlay,项目名称:lightspark,代码行数:12,代码来源:ByteArray.cpp
注:本文中的tiny_string类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论