// stores the texts \r
if (!disable_tc)\r
Text->Save(fp);\r
-\r
+ if (!disable_tc){\r
+ int st = CachedText.size();\r
+ ufwrite(&st, sizeof(int),1,fp);\r
+ for (int i = 0; i< CachedText.size(); ++i){\r
+ st = CachedText.at(i).size();\r
+ ufwrite(&st, sizeof(int),1,fp);\r
+ ufwrite(CachedText.at(i).c_str(),sizeof(char),(1+strlen(CachedText.at(i).c_str())),fp);\r
+ };\r
+ };\r
fclose(fp);\r
\r
}\r
if (!XML_Tree->disable_tc){\r
XML_Tree->Text = TextCollection::InitTextCollection(sample_rate_text);\r
XML_Tree->Text->Load(fp,sample_rate_text);\r
+ int sst;\r
+ int st;\r
+ ufread(&sst, sizeof(int),1,fp);\r
+ for (int i=0;i<sst;i++){\r
+ ufread(&st, sizeof(int),1,fp);\r
+ char* str = (char*) malloc(sizeof(char)*st+1);\r
+ ufread(str,sizeof(char),st+1,fp);\r
+ string cppstr = str;\r
+ XML_Tree->CachedText.push_back(cppstr);\r
+ free(str);\r
+ };\r
+\r
}\r
else\r
XML_Tree->Text = NULL;\r
\r
s_text = ftell(fp) - s_text;\r
+\r
+ \r
+\r
+\r
fclose(fp);\r
\r
std::cerr << "Tree part is " << s_tree/1024 << " Kbytes,\n"\r
tags_aux[npar] = i; // inserts the new tag id within the preorder sequence of tags\r
\r
npar++;\r
-\r
+ \r
return 1;\r
\r
}\r
}\r
\r
Text->InsertText(s);\r
+ string cpps = (char*) s;\r
+ CachedText.push_back(cpps); \r
\r
return 1; // success\r
}\r
\r
/** The texts in the XML document */\r
TextCollection *Text;\r
+ /** The texts in the XML document (cached for faster display) */\r
+ vector<string> CachedText;\r
\r
/** Flag indicating whether the whole data structure has been constructed or \r
* not. If the value is true, you cannot add more texts, nodes, etc. */\r
uchar* GetText(DocID d) {\r
return Text->GetText(d);\r
}\r
+\r
+ uchar* GetCachedText(DocID d) {\r
+ return (uchar*) (CachedText.at(d).c_str());\r
+ }\r
\r
TextCollection *getTextCollection() {\r
return Text;\r