本文整理汇总了C++中CharString::split方法的典型用法代码示例。如果您正苦于以下问题:C++ CharString::split方法的具体用法?C++ CharString::split怎么用?C++ CharString::split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CharString
的用法示例。
在下文中一共展示了CharString::split方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
APIModVersion::APIModVersion(CharString versionstr){ // discards name split from ':', only keeps version number
major = minor = submajor = subminor = 0;
atleastver = false;
// forget modname if it is still in the string
if(versionstr.contains(":")){
LinkedList<CharString> vsplit = versionstr.split(":");
versionstr = vsplit[1];
}
this->versionstring = versionstr; // keep original string
if(versionstr.startsWith(">")){
atleastver = true;
versionstr.shiftLeft(1);
}
if(versionstr.startsWith("v")) versionstr.shiftLeft(1);
if(versionstr.contains(".")){
LinkedList<CharString> vsplit = versionstr.split(".");
if(vsplit[0].isValidNumber()) major = vsplit[0].getInt();
if(vsplit[1].isValidNumber()) minor = vsplit[1].getInt();
if(vsplit.size() >= 3 && vsplit[2].isValidNumber()) submajor = vsplit[2].getInt();
if(vsplit.size() >= 4 && vsplit[3].isValidNumber()) subminor = vsplit[3].getInt();
}else{
// what? Single version number?
if(versionstr.isValidNumber()){
major = versionstr.getInt();
}else{
// dunno...
cout << "API Mod Version could not figure out the version for " << versionstring << endl;
}
}
}
示例2: _msgClientHandler_ANY_recv
void _msgClientHandler_ANY_recv(MSGServer *serv, MSGClient* cli, CharString dataIn, CharString &dataOut){
// handles any message type.
if(dataIn.startsWith("channel:publish:")){ // channel publish data (to here!)
// channel:publish:CHANNAME:DATA
LinkedList<CharString> c = dataIn.split(":");
// +":id" when sent to other channels
MSGClientChannel* chan = serv->getMSGChannel(c[2]);
if(chan != 0x0){
CharString pack = dataIn;
pack += ":";
pack += cli->identity;
chan->distributemessagepacket(pack); // send out the goods
}
}else if(dataIn.startsWith("channel:subscribe:")){ // client subscribes to channel
// channel:subscribe:CHANNAME
}else if(dataIn.startsWith("channel:unsubscribe:")){ // client unsubscribes from channel
// channel:unsubscribe:CHANNAME
}else if(cli->isbserver) { // Is another broadcast server???
if(dataIn.startsWith("newid:")){ // sent from other server
// newid:IP:ID
}else if(dataIn.startsWith("newchannel:")){ // new messaging channel
// newchannel:NAME
}else if(dataIn.startsWith("newsubscriber:")){ // new subscriber for the channel
// newsubscriber:NAME:ID
}else if(dataIn.startsWith("unsubscriber:")){ // channel unsub
// unsubscriber:NAME:ID
}
}
}
示例3: getNameFromString
/* Returns the name of the end point.
* Input: String location
* Output: Very ending of string after last "/"
*/
CharString FileSystem::getNameFromString(CharString location) {
// gets the name of the last "/dir/dir2/name", even if it ends with "/".
if(location.get()[location.getSize()-1] == '/') {
// remove trailing "/".
location.get()[location.getSize()-1] = '\0';
location.setSize(location.getSize()-1);
}
CharString result = CharString("");
// split all by "/".
if(location.contains("/")) {
// get the very last result of the split.
LinkedList<CharString>* sresult = location.split('/','`');
result = *sresult->get(sresult->size()-1);
} else {
result = location;
}
return result;
}
示例4: loadProperties
// LinkedList<LinkedList<CharString>> lines = SimpleParseFile(file, '\n');
void APIMod::loadProperties(){ // , CharString name, CharString language, CharString version
if(propertiesloaded) return;
LinkedList<LinkedList<CharString>> lines = SimpleParseString(getModFileData("mod.properties"), '=');
CharString depvers = "";
LinkedListIterator<LinkedList<CharString>> lineit = lines.getIterator();
while(lineit.hasNext()){
LinkedList<CharString> p = lineit.next();
CharString pname = p[0];
if(pname.compare(CharString("name")))
this->name = p[1];
else if(pname.compare(CharString("unixname")))
this->unixname = p[1];
else if(pname.compare(CharString("language"))) // c++, java, etc.
this->language = p[1];
else if(pname.compare(CharString("version"))){
this->versionstr = p[1];
this->version = APIModVersion(p[1]);
}else if(pname.compare(CharString("dependency_versions")))
depvers = p[1];
}
this->modcwdloc = unixname; // relative folder location for mod
// load dependency versioning information
// this->dependencyversions.add("mod1:v12938");
if(depvers.getSize() > 3){
if(depvers.contains(", ")){
depvers.replace(" ", "");
LinkedList<CharString> v = depvers.split(",");
this->dependencyversions.addAll(v);
}else{
this->dependencyversions.add(depvers);
}
}
propertiesloaded=true;
}
示例5: compareVersionString
bool APIMod::compareVersionString(CharString verstr){
LinkedList<CharString> spl = verstr.split(":");
CharString name = spl[0];
CharString ver = spl[1];
}