00001
00002
00003 #include "xmlUtil/id/IdOpTruncate.h"
00004 #include "xml/Dom.h"
00005
00006 namespace xmlUtil {
00007
00008 IdOpTruncate::IdOpTruncate(DOM_Element trunc) {
00009
00010 start = xml::Dom::getAttribute(trunc, "start");
00011 std::string beyondVal = xml::Dom::getAttribute(trunc, "beyond");
00012 beyond = (beyondVal.compare(std::string("true")) == 0);
00013 }
00014
00015 NamedId * IdOpTruncate::convert(const NamedId& inputId) {
00016
00017 int nToCopy;
00018 if ((nToCopy = inputId.hasField(start)) < 0) return 0;
00019
00020 if (beyond) ++nToCopy;
00021 NamedId *newId = new NamedId(inputId, nToCopy);
00022 return newId;
00023 }
00024
00025 }