41 static std::string
join(
const std::list<std::string> & strings)
44 std::list<std::string>::const_iterator it;
45 for (it=strings.begin(); it!=strings.end(); it++)
53 _documentHandler->
read(is);
58 _documentHandler->
create(name.c_str());
59 _lastWasContent=
false;
96 _useIndentation=useIndentation;
105 _lastWasContent =
true;
106 _useIndentation =
false;
110 delete _documentHandler;
115 std::ifstream is(filename.c_str());
116 std::ostringstream os;
117 os <<
"Restoring from an unopened file with filename <" << filename <<
">" << std::flush;
124 std::ofstream os(filename.c_str());
125 CLAM_WARNING(os.is_open(),
"Dumping on an unopened file");
126 Dump(obj,rootName,os);
133 std::ifstream is (filename.c_str());
140 std::ofstream os(filename.c_str());
149 const XMLable * xmlable =
dynamic_cast<const XMLable *
>(&storable);
150 const char * name = xmlable->
XMLName();
153 StoreContentAndChildren(xmlable);
163 _lastWasContent=
false;
166 StoreContentAndChildren(xmlable);
168 _lastWasContent=
false;
177 if (!xmlable)
return false;
180 return LoadContentAndChildren(xmlable);
188 LoadContentAndChildren(xmlable);
190 _errors +=
join(innerContext.errors());
197 std::stringstream stream;
209 bool XmlStorage::LoadContentAndChildren(
XMLable* xmlable)
213 if (component) component->
LoadFrom(*
this);
217 void XmlStorage::StoreContentAndChildren(
const XMLable * xmlable)
219 AddContentToElement(xmlable->XMLContent());
220 StoreChildrenIfComponent(xmlable);
223 void XmlStorage::StoreChildrenIfComponent(
const XMLable * xmlable)
225 const Component * component =
dynamic_cast<const Component *
>(xmlable);
226 if (component) component->
StoreOn(*
this);
229 void XmlStorage::AddContentToElement(
const std::string & content)
231 if (content==
"")
return;
235 _lastWasContent =
true;