예제 #1
0
int main(){

	exception e;
	int i = 0,t,result,len,count=0;
	UCSChar *tmpStr = NULL;
	UByte* xml = "<root>good</root>";
	VTDGen *vg = NULL;
	VTDNav *vn = NULL;
	Try{
		vg = createVTDGen();
		setDoc(vg,xml,strlen(xml));
		parse(vg,TRUE);
		vn = getNav(vg);
		i = getText(vn);
		tmpStr = toString(vn,i);
		wprintf(L" text value is %s\n",tmpStr);
		free(tmpStr);
		len=strlen("bad");
		overWrite(vn,i,"bad",0,len);
		tmpStr = toString(vg,i);
		wprintf(L" text value is %s\n",tmpStr);
		free(tmpStr);
		// remember C has no automatic garbage collector
		// needs to deallocate manually.
		freeVTDNav(vn);
		freeVTDGen(vg);
	}
	Catch (e) {
		// manual garbage collection here
		freeVTDGen(vg);
	}
  return 0;
}	
예제 #2
0
int main(){
	exception e;
	VTDGen *vg = NULL;
	VTDNav *vn = NULL;
	AutoPilot *ap1 = NULL;
	FILE *f = NULL;
	UCSChar *string = NULL;
	int i;
	Try{			
		vg = createVTDGen();		
		if (parseFile(vg,TRUE,"d:/ximpleware_2.2_c/vtd-xml/codeGuru/13/old_cd.xml")==FALSE){
			free(vg->XMLDoc);
			freeVTDGen(vg);
			return 0;
		}	
		ap1 = createAutoPilot2();
		selectXPath(ap1,L"/CATALOG/CD[PRICE=10.2]/*/text()");
		vn = getNav(vg);
		bind(ap1,vn);
		while((i=evalXPath(ap1))!=-1){
			overWrite(vn,i,"",0,0);		
		}
		f= fopen("d:/ximpleware_2.2_c/vtd-xml/codeGuru/13/new_cd.xml","wb");
		fwrite(vn->XMLDoc+vn->docOffset,1,vn->docLen,f);
		fclose(f);
		free(vn->XMLDoc);
	}Catch(e){// handle various types of exceptions here
	}
	freeAutoPilot(ap1);
	freeVTDGen(vg);
	freeVTDNav(vn);
	return 0;
}
예제 #3
0
파일: erase.c 프로젝트: CoolBalance/vtd-xml
void main(){
	exception e;
	Try{
		VTDGen *vg = NULL; /* This is the VTDGen that parses XML */
		VTDNav *vn = NULL; /* This is the VTDNav that navigates the VTD records */
		AutoPilot *ap = NULL, *ap2=NULL;
		XMLModifier *xm = NULL;
		ElementFragmentNs *ef = NULL;
		int i= -1;
		Long l= -1;

		vg = createVTDGen();
		ap = createAutoPilot2();
		ap2 = createAutoPilot2();
		xm = createXMLModifier();
		//selectXPath(ap,L"(/*/*/*)[position()>1 and position()<4]");
		selectXPath(ap2,L"//@*");
		if (parseFile(vg,TRUE,"soap2.xml")){
			FILE *f1 = fopen("new3.xml","wb");
			vn = getNav(vg);
			//bind(ap,vn);
			bind(ap2,vn);
			//bind4XMLModifier(xm,vn);
			//i=evalXPath(ap2);
			//printf(" i's value is %d \n",i);
			//l=getElementFragment(vn);
			//ef = getElementFragmentNs(vn);
			//writeFragmentToFile(ef,f1);
			//fclose(f1);
			
			while( (i=evalXPath(ap2))!=-1){
				//insertAfterElement4(xm,ef);
				//insertAfterElement3(xm,vn->XMLDoc,(int)l,(int)(l>>32));
				printf(" i's value is %d \n",i);
				overWrite(vn,i+1,"",0,0);
			}
			fwrite(vn->XMLDoc+vn->docOffset,sizeof(UByte),vn->docLen,f1);
			//output2(xm,"d:/new3.xml");
			fclose(f1);
			free(vn->XMLDoc);
			freeVTDNav(vn);
		}
		freeElementFragmentNs(ef);
		freeXMLModifier(xm);
		freeAutoPilot(ap);
		freeAutoPilot(ap2);
		freeVTDGen(vg);
		
	}Catch(e){
		printf("exception !!!!!!!!!!! \n");
	}
}
예제 #4
0
int Mgr::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: cellChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: readFinish((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break;
        case 2: onCid((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 3: timecall(); break;
        case 4: debugfn(); break;
        case 5: savescode((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 6: saveLoc((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3]))); break;
        case 7: { bool _r = isSaved((*reinterpret_cast< QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 8: overWrite((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3]))); break;
        case 9: quit(); break;
        default: ;
        }
        _id -= 10;
    }
    return _id;
}
 void ExperimentalRingbuffer::overWrite(shared_ptr<geometry::CNPoint2D> p)
 {
     overWrite(p, 1);
 }