コード例 #1
0
void scStringSplit(CScriptVar *c, void *) {
    string str = c->getParameter("this")->getString();
    string sep = c->getParameter("separator")->getString();
    CScriptVar *result = c->getReturnVar();
    result->setArray();
    int length = 0;

    size_t pos = str.find(sep);
    while (pos != string::npos) {
      result->setArrayIndex(length++, new CScriptVar(str.substr(0,pos)));
      str = str.substr(pos+1);
      pos = str.find(sep);
    }

    if (str.size()>0)
      result->setArrayIndex(length++, new CScriptVar(str));
}
コード例 #2
0
void scStringSplit(CScriptVar *c, void *userdata) {
    IGNORE_PARAMETER(userdata);
    wString str = c->getParameter("this")->getString();
    wString sep = c->getParameter("separator")->getString();
    CScriptVar *result = c->getReturnVar();
    result->setArray();
    int length = 0;
    
    //consider sepatator length;
    int inc = sep.length();
    size_t pos = str.find(sep);
    while (pos != wString::npos) {
        result->setArrayIndex(length++, new CScriptVar(str.substr(0,pos)));
        str = str.substr(pos+inc);
        pos = str.find(sep);
    }
    
    if (str.size()>0)
    result->setArrayIndex(length++, new CScriptVar(str));
}
コード例 #3
0
void scKeys(CScriptVar *c, void *userdata) {
    IGNORE_PARAMETER(userdata);
    wString list = c->getParameter("obj")->trace2();
    list.CalcCount();
    //wString str = c->getParameter("this")->getString();
    //wString sep = c->getParameter("separator")->getString();
    CScriptVar *result = c->getReturnVar();
    result->setArray();
    int length = 0;
    
    for( int i = 0 ; i < list.Count() ; i++ ){
        result->setArrayIndex(length++, new CScriptVar(list.GetListString(i)));
    }
}