void FourSectionDictionary::save(std::ostream & output, ControlInformation & controlInformation, ProgressListener *listener)
{
	controlInformation.setFormat(HDTVocabulary::DICTIONARY_TYPE_FOUR);

	controlInformation.setUint("mapping", this->mapping);
	controlInformation.setUint("sizeStrings", this->sizeStrings);

	controlInformation.save(output);

	IntermediateListener iListener(listener);

	iListener.setRange(0,10);
	iListener.notifyProgress(0, "Dictionary save shared area.");
	shared->save(output);

	iListener.setRange(10,45);
	iListener.notifyProgress(0, "Dictionary save subjects.");
	subjects->save(output);

	iListener.setRange(45,60);
	iListener.notifyProgress(0, "Dictionary save predicates.");
	predicates->save(output);

	iListener.setRange(60,100);
	iListener.notifyProgress(0, "Dictionary save objects.");
	objects->save(output);
}
Beispiel #2
0
void PlainDictionary::save(std::ostream &output, ControlInformation &controlInformation, ProgressListener *listener)
{
    controlInformation.setFormat(HDTVocabulary::DICTIONARY_TYPE_PLAIN);
    controlInformation.setUint("mapping", this->mapping);
    controlInformation.setUint("sizeStrings", this->sizeStrings);
    controlInformation.setUint("numEntries", this->getNumberOfElements());

    controlInformation.save(output);

    unsigned int i = 0;
    unsigned int counter=0;
    const char marker = '\1';

    //shared subjects-objects from subjects
    for (i = 0; i < shared.size(); i++) {
        output << shared[i]->str;
        output.put(marker); //character to split file
        counter++;
        NOTIFYCOND(listener, "PlainDictionary saving shared", counter, getNumberOfElements());
    }

    output.put(marker); //extra line to set the begining of next part of dictionary

    //not shared subjects
    for (i = 0; i < subjects.size(); i++) {
        output << subjects[i]->str;
        output.put(marker); //character to split file
        counter++;
        NOTIFYCOND(listener, "PlainDictionary saving subjects", counter, getNumberOfElements());
    }

    output.put(marker); //extra line to set the begining of next part of dictionary

    //not shared objects
    for (i = 0; i < objects.size(); i++) {
        output << objects[i]->str;
        output.put(marker); //character to split file
        counter++;
        NOTIFYCOND(listener, "PlainDictionary saving objects", counter, getNumberOfElements());
    }

    output.put(marker); //extra line to set the begining of next part of dictionary

    //predicates
    for (i = 0; i < predicates.size(); i++) {
        output << predicates[i]->str;
        output.put(marker); //character  to split file
        counter++;
        NOTIFYCOND(listener, "PlainDictionary saving predicates", counter, getNumberOfElements());
    }

    output.put(marker);
}
void CompactTriples::save(std::ostream & output, ControlInformation &controlInformation, ProgressListener *listener)
{
	controlInformation.clear();
	controlInformation.setUint("numTriples", getNumberOfElements());
	controlInformation.setFormat(HDTVocabulary::TRIPLES_TYPE_COMPACT);
	controlInformation.setUint("order", order);
	controlInformation.save(output);

	IntermediateListener iListener(listener);

	iListener.setRange(0,30);
	iListener.notifyProgress(0, "CompactTriples saving Stream Y");
	streamY->save(output);

	iListener.setRange(30,100);
	iListener.notifyProgress(0, "CompactTriples saving Stream Z");
	streamZ->save(output);
}
Beispiel #4
0
void PlainTriples::save(std::ostream & output, ControlInformation &controlInformation, ProgressListener *listener)
{
	controlInformation.clear();
	controlInformation.setUint("numTriples", getNumberOfElements());
	controlInformation.setFormat(HDTVocabulary::TRIPLES_TYPE_PLAIN);
	controlInformation.setUint("order", order);
	controlInformation.save(output);

	IntermediateListener iListener(listener);

	iListener.setRange(0,33);
	iListener.notifyProgress(0, "PlainTriples saving subjects");
	streamX->save(output);

	iListener.setRange(33, 66);
	iListener.notifyProgress(0, "PlainTriples saving predicates");
	streamY->save(output);

	iListener.setRange(66, 100);
	iListener.notifyProgress(0, "PlainTriples saving objects");
	streamZ->save(output);
}
void PlainHeader::save(std::ostream & output, ControlInformation &controlInformation, ProgressListener *listener)
{
	// TODO: Choose format from spec (NTRIPLES, RDFXML...) and implement.

	// Dump header into a stringbuffer to know size.
	stringstream strbuf(stringstream::out);
	for(vector<TripleString>::iterator it = triples.begin(); it!=triples.end(); it++){
		strbuf << *it << " ." << endl;
	}
	string str = strbuf.str();

	// Dump header
	controlInformation.setFormat(HDTVocabulary::HEADER_NTRIPLES);
	controlInformation.setUint("length", str.length());
	controlInformation.save(output);

	// Dump data
	output << str;
}