⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stafdatatypes.cpp

📁 Software Testing Automation Framework (STAF)的开发代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
            STAFObjectMapPut(mapObj, key.getImpl(), obj);            STAFObjectDestruct(&obj);        }        STAFObjectMarshallingContextSetRootObject(*newContext, mapObj);        STAFObjectDestruct(&mapObj);    }    else if (data.startsWith(mcInstanceMarker))    {        STAFObject_t mapObj = 0;        STAFObjectConstructMap(&mapObj);        // Skip past overall length of the map class instance and then get the        // map class name        unsigned int dataIndex = data.find(sColon);        dataIndex = data.find(sColon, dataIndex + 1) + 1;        STAFString mapClassName = getCLCString(data, dataIndex);        // Now add the map class name to the map        STAFObject_t mapClassNameObj = 0;        STAFObjectConstructScalarString(&mapClassNameObj,                                        mapClassName.getImpl());        STAFObjectMapPut(mapObj, sMapClassKey.getImpl(), mapClassNameObj);        STAFObjectDestruct(&mapClassNameObj);        // Now unmarshall all the actual keys        STAFObject_t mapClassObj =            (*context->contextValue->mapClassMap->mapValue)[mapClassName];        STAFObject_t keyList = (*mapClassObj->mapValue)["keys"];        STAFObjectList::iterator iter = keyList->listValue->begin();        while (dataIndex < data.length())        {            STAFObject_t keyStringObj =  (*(*iter)->mapValue)["key"];            STAFString_t keyImpl = keyStringObj->scalarStringValue->getImpl();            STAFObject_t obj = unmarshallObject(data, context, dataIndex, flags);            STAFObjectMapPut(mapObj, keyImpl, obj);            STAFObjectDestruct(&obj);            ++iter;        }        STAFObjectMarshallingContextSetRootObject(*newContext, mapObj);        STAFObjectDestruct(&mapObj);    }    else if (data.startsWith(contextMarker))    {        unsigned int colonIndex = data.find(sColon);        unsigned int dataIndex = data.find(sColon, colonIndex + 1) + 1;        STAFObject_t contextMap = unmarshallObject(data, 0, dataIndex, flags);        // Now we need to take ownership of the underlying map class map.  So,        //        // 1) Destruct the existing map class map in the new context        // 2) "Adopt" the map class map from the context map        // 3) Construct a None in the place of the "adopted" map class map in        //    the context map        // 4) Destruct the context map since we don't need it any more        STAFObjectDestruct(&(*newContext)->contextValue->mapClassMap);        (*newContext)->contextValue->mapClassMap =            (*contextMap->mapValue)["map-class-map"];        STAFObjectConstructNone(&(*contextMap->mapValue)["map-class-map"]);        STAFObjectDestruct(&contextMap);        // Now, get and set the root object        STAFObject_t rootObject = unmarshallObject(data, *newContext, dataIndex,                                                   flags);        STAFObjectMarshallingContextSetRootObject(*newContext, rootObject);        STAFObjectDestruct(&rootObject);    }    else    {        // We don't know what this data is, so just return a Scalar String        // object containing the whole string        STAFObject_t stringObj = 0;        STAFObjectConstructScalarString(&stringObj, data.getImpl());        STAFObjectMarshallingContextSetRootObject(*newContext, stringObj);        STAFObjectDestruct(&stringObj);    }    return kSTAFOk;}STAFRC_t STAFObjectListAppend(STAFObject_t list, STAFObject_t obj){    if (list == 0) return kSTAFInvalidObject;    if (obj  == 0) return kSTAFInvalidParm;    // XXX: Might this want to be a new kSTAFInvalidOperation ?    if (list->type != kSTAFListObject) return kSTAFInvalidObject;    // Note: The object being passed in gets turned into a reference    STAFObject_t newObj = new STAFObjectImpl(*obj);    obj->isRef = true;    list->listValue->push_back(newObj);    return kSTAFOk;}STAFRC_t STAFObjectIteratorHasNext(STAFObjectIterator_t iter,                                   unsigned int *hasNext){    if (iter    == 0) return kSTAFInvalidObject;    if (hasNext == 0) return kSTAFInvalidParm;    if (iter->type == kSTAFObjectListIterator)    {        *hasNext = (iter->listIterator->iter ==                    iter->listIterator->listObject->end()) ? 0 : 1;    }    else if ((iter->type == kSTAFObjectMapKeyIterator) ||             (iter->type == kSTAFObjectMapValueIterator))    {        *hasNext = (iter->mapIterator->iter ==                    iter->mapIterator->mapObject->end()) ? 0 : 1;    }    else    {        // XXX: Return an error?        *hasNext = 0;    }    return kSTAFOk;}STAFRC_t STAFObjectIteratorGetNext(STAFObjectIterator_t iter,                                   STAFObject_t *pObject){    if (iter    == 0) return kSTAFInvalidObject;    if (pObject == 0) return kSTAFInvalidParm;    if (iter->type == kSTAFObjectListIterator)    {        STAFObjectConstructReference(pObject, *iter->listIterator->iter);        ++iter->listIterator->iter;    }    else if (iter->type == kSTAFObjectMapKeyIterator)    {        STAFObjectConstructScalarString(            pObject, iter->mapIterator->iter->first.getImpl());        ++iter->mapIterator->iter;    }    else if (iter->type == kSTAFObjectMapValueIterator)    {        STAFObjectConstructReference(pObject, iter->mapIterator->iter->second);        ++iter->mapIterator->iter;    }    else return kSTAFInvalidObject;    return kSTAFOk;}STAFRC_t STAFObjectIteratorDestruct(STAFObjectIterator_t *iter){    if (iter  == 0) return kSTAFInvalidObject;    if (*iter == 0) return kSTAFInvalidObject;    if ((*iter)->type == kSTAFObjectListIterator)        delete (*iter)->listIterator;    else        delete (*iter)->mapIterator;    delete *iter;    *iter = 0;    return kSTAFOk;}STAFRC_t STAFObjectMapHasKey(STAFObject_t map, STAFStringConst_t key,                             unsigned int *pHasKey){    if (map     == 0) return kSTAFInvalidObject;    if (key     == 0) return kSTAFInvalidParm;    if (pHasKey == 0) return kSTAFInvalidParm;    // XXX: Might this want to be a new kSTAFInvalidOperation ?    if (map->type != kSTAFMapObject) return kSTAFInvalidObject;    STAFObjectMap::iterator iter = map->mapValue->find(key);    if (iter == map->mapValue->end())        *pHasKey = 0;    else        *pHasKey = 1;    return kSTAFOk;}STAFRC_t STAFObjectMapGet(STAFObject_t map, STAFStringConst_t key,                          STAFObject_t *pObject){    if (map     == 0) return kSTAFInvalidObject;    if (key     == 0) return kSTAFInvalidParm;    if (pObject == 0) return kSTAFInvalidParm;    // XXX: Might this want to be a new kSTAFInvalidOperation ?    if (map->type != kSTAFMapObject) return kSTAFInvalidObject;    STAFObjectMap::iterator iter = map->mapValue->find(key);    if (iter == map->mapValue->end())        STAFObjectConstructNone(pObject);    else        STAFObjectConstructReference(pObject, iter->second);    return kSTAFOk;}STAFRC_t STAFObjectMapPut(STAFObject_t map, STAFStringConst_t key,                          STAFObject_t obj){    if (map == 0) return kSTAFInvalidObject;    if (key == 0) return kSTAFInvalidParm;    if (obj == 0) return kSTAFInvalidParm;    // XXX: Might this want to be a new kSTAFInvalidOperation ?    if (map->type != kSTAFMapObject) return kSTAFInvalidObject;    // If there is already something associated with this key, we have to    // get rid of it first    STAFObjectMap::iterator iter = map->mapValue->find(key);    if (iter != map->mapValue->end())    {        STAFObjectDestruct(&iter->second);    }    // Now add the new object    // Note: The object being passed in gets turned into a reference    STAFObject_t newObj = new STAFObjectImpl(*obj);    obj->isRef = true;    (*map->mapValue)[key] = newObj;    return kSTAFOk;}STAFRC_t STAFObjectMarshallingContextSetMapClassDefinition(    STAFObject_t context,    STAFStringConst_t name,    STAFObject_t obj){    if (context == 0) return kSTAFInvalidObject;    if (name    == 0) return kSTAFInvalidParm;    if (obj     == 0) return kSTAFInvalidParm;    // XXX: Might this want to be a new kSTAFInvalidOperation ?    if (context->type != kSTAFMarshallingContextObject)        return kSTAFInvalidObject;    // XXX: We need to do a good bit of checking to ensure that the map class    //      definition is valid    // If there is already something associated with this key, we have to    // get rid of it first    STAFObjectMap::iterator iter =        context->contextValue->mapClassMap->mapValue->find(name);    if (iter != context->contextValue->mapClassMap->mapValue->end())    {        STAFObjectDestruct(&iter->second);    }    // Now add the new object    // Note: The object being passed in gets turned into a reference    STAFObject_t newObj = new STAFObjectImpl(*obj);    obj->isRef = true;    (*context->contextValue->mapClassMap->mapValue)[name] = newObj;    return kSTAFOk;}STAFRC_t STAFObjectMarshallingContextGetMapClassDefinition(    STAFObject_t context,    STAFStringConst_t name,    STAFObject_t *pObject){    if (context == 0) return kSTAFInvalidObject;    if (name    == 0) return kSTAFInvalidParm;    if (pObject == 0) return kSTAFInvalidParm;    // XXX: Might this want to be a new kSTAFInvalidOperation ?    if (context->type != kSTAFMarshallingContextObject)        return kSTAFInvalidObject;    STAFObjectMap::iterator iter =        context->contextValue->mapClassMap->mapValue->find(name);    if (iter == context->contextValue->mapClassMap->mapValue->end())        STAFObjectConstructNone(pObject);    else        STAFObjectConstructReference(pObject, iter->second);    return kSTAFOk;}STAFRC_t STAFObjectMarshallingContextHasMapClassDefinition(    STAFObject_t context,    STAFStringConst_t name,    unsigned int *pHasMapClassDefinition){    if (context                == 0) return kSTAFInvalidObject;    if (name                   == 0) return kSTAFInvalidParm;    if (pHasMapClassDefinition == 0) return kSTAFInvalidParm;    // XXX: Might this want to be a new kSTAFInvalidOperation ?    if (context->type != kSTAFMarshallingContextObject)        return kSTAFInvalidObject;    return STAFObjectMapHasKey(context->contextValue->mapClassMap, name,                               pHasMapClassDefinition);}STAFRC_t STAFObjectMarshallingContextSetRootObject(STAFObject_t context,                                                   STAFObject_t obj){    if (context == 0) return kSTAFInvalidObject;    if (obj     == 0) return kSTAFInvalidParm;    // XXX: Might this want to be a new kSTAFInvalidOperation ?    if (context->type != kSTAFMarshallingContextObject)        return kSTAFInvalidObject;    // Get rid of the old root object    STAFObjectDestruct(&context->contextValue->rootObject);    // Now set the new root object    // Note: The object being passed in gets turned into a reference    context->contextValue->rootObject = new STAFObjectImpl(*obj);    obj->isRef = true;    return kSTAFOk;}STAFRC_t STAFObjectMarshallingContextGetRootObject(STAFObject_t context,                                                   STAFObject_t *pObject){    if (context == 0) return kSTAFInvalidObject;    if (pObject == 0) return kSTAFInvalidParm;    // XXX: Might this want to be a new kSTAFInvalidOperation ?    if (context->type != kSTAFMarshallingContextObject)        return kSTAFInvalidObject;    STAFObjectConstructReference(pObject, context->contextValue->rootObject);    return kSTAFOk;}STAFRC_t STAFObjectMarshallingContextAdoptRootObject(STAFObject_t context,                                                     STAFObject_t *pObject){    if (context == 0) return kSTAFInvalidObject;    if (pObject == 0) return kSTAFInvalidParm;    // XXX: Might this want to be a new kSTAFInvalidOperation ?    if (context->type != kSTAFMarshallingContextObject)        return kSTAFInvalidObject;    // Copy our root object into the destination    *pObject = new STAFObjectImpl(*context->contextValue->rootObject);    // Note: The marshalling context root object is now a reference    context->contextValue->rootObject->isRef = true;    return kSTAFOk;}STAFRC_t STAFObjectMarshallingContextGetPrimaryObject(STAFObject_t context,                                                      STAFObject_t *pObject){    if (context == 0) return kSTAFInvalidObject;    if (pObject == 0) return kSTAFInvalidParm;    // XXX: Might this want to be a new kSTAFInvalidOperation ?    if (context->type != kSTAFMarshallingContextObject)        return kSTAFInvalidObject;    if (context->contextValue->mapClassMap->mapValue->size() != 0)        STAFObjectConstructReference(pObject, context);    else        STAFObjectConstructReference(pObject, context->contextValue->rootObject);    return kSTAFOk;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -