#include <IdConversion.h>
Public Methods | |
| IdConversion () | |
| Default constructor produces a conversion which acts on any NamedId and does nothing to it; that is, returns a copy. More... | |
| IdConversion (const DOM_Element) | |
| The usual case: build a conversion from its XML description. More... | |
| ~IdConversion () | |
| bool | inDomain (const NamedId &inputId) |
| Check that start of inputId fieldnames match path. More... | |
| NamedId * | convert (const NamedId &inputId) |
| Convert the identifier if in domain; else return null. More... | |
| bool | subpathOf (const IdConversion &other) const |
| Return true if our path is subpath of other. More... | |
Private Types | |
| typedef std::string | Condition |
| For now only condition recognized is hasField, which can be represented by a string: the field name. More... | |
Private Methods | |
| bool | satisfies (const NamedId &inputId) |
| NamedId * | internalConvert (const NamedId &inputId) |
| Doesn't check that input is in domain. Typically invoked from convert. More... | |
| void | makePath (const DOM_Element &pathElt) |
| Form path component from corresponding piece of xml. More... | |
| void | buildOp (const DOM_Element &optElt) |
| Determine operation type and instantiate object of appropriate operation class. More... | |
Private Attributes | |
| NameSeq * | m_path |
| Defines domain of conversion. More... | |
| Condition * | m_condition |
| Given an identifier in domain, convert if condition is satisfied. More... | |
| IdOperation * | m_op |
| op knows how to do a conversion. More... | |
Friends | |
| class | IdConverterLessThan |
| std::ostream & | operator<< (std::ostream &s, const IdConversion &convers) |
Definition at line 23 of file IdConversion.h.
|
|
For now only condition recognized is hasField, which can be represented by a string: the field name.
Definition at line 68 of file IdConversion.h. |
|
|
Default constructor produces a conversion which acts on any NamedId and does nothing to it; that is, returns a copy.
Definition at line 12 of file IdConversion.cxx. References m_op.
00012 : m_path(0), m_condition(0) { 00013 m_op = new IdOperation(); 00014 } |
|
|
The usual case: build a conversion from its XML description.
Definition at line 16 of file IdConversion.cxx. References buildOp(), m_condition, and makePath().
00016 {
00017
00018 // Get first child; invoke private function to build path
00019 DOM_Element child = xml::Dom::getFirstChildElement(conversion);
00020 makePath(child);
00021
00022 // Get next child; save field name in condition component
00023 child = xml::Dom::getSiblingElement(child);
00024 m_condition = new std::string(xml::Dom::getAttribute(child, "name"));
00025
00026 // Get next child; build new op component.
00027 child = xml::Dom::getSiblingElement(child);
00028 buildOp(child);
00029 }
|
|
|
|
|
|
Determine operation type and instantiate object of appropriate operation class.
Definition at line 72 of file IdConversion.cxx. References m_op. Referenced by IdConversion().
00072 {
00073 DOMString opType = opElt.getTagName();
00074
00075 if (opType.equals("truncate"))
00076 {
00077 m_op = new IdOpTruncate(opElt);
00078 }
00079 else if (opType.equals("disappear")) {
00080 m_op = new IdOpDisappear(opElt);
00081 }
00082 else if (opType.equals(DOMString("compress"))) {
00083 m_op = new IdOpCompress(opElt);
00084 }
00085 else { // default to identity operation, implemented by base class
00086 m_op = new IdOperation(opElt);
00087 }
00088 }
|
|
|
Convert the identifier if in domain; else return null.
Definition at line 41 of file IdConversion.cxx. References inDomain(), and internalConvert().
00041 {
00042 if (!inDomain(inputId)) return 0;
00043 return internalConvert(inputId);
00044 }
|
|
|
Check that start of inputId fieldnames match path.
Definition at line 31 of file IdConversion.cxx. References m_path. Referenced by convert().
00031 {
00032 return inputId.hasSubpath(*m_path);
00033 }
|
|
|
Doesn't check that input is in domain. Typically invoked from convert.
Definition at line 46 of file IdConversion.cxx. References m_op, and satisfies(). Referenced by convert().
|
|
|
Form path component from corresponding piece of xml.
Definition at line 55 of file IdConversion.cxx. References m_path, and xmlUtil::NameSeq. Referenced by IdConversion().
00055 {
00056
00057 // "path" consists of a list of fields. Fields have
00058 // a required attribute "name". Save its value.
00059 m_path = new NameSeq;
00060 DOM_Element child = xml::Dom::getFirstChildElement(pathElt);
00061
00062 while (child != DOM_Element()) {
00063 m_path->push_back(new std::string(xml::Dom::getAttribute(child, "name")));
00064 child = xml::Dom::getSiblingElement(child);
00065 }
00066
00067 }
|
|
|
Definition at line 35 of file IdConversion.cxx. References m_condition. Referenced by internalConvert().
00035 {
00036 if (m_condition == 0) return true;
00037
00038 return (inputId.hasField(*m_condition) >= 0);
00039 }
|
|
|
Return true if our path is subpath of other.
Definition at line 91 of file IdConversion.cxx. References m_path.
|
|
|
Definition at line 49 of file IdConversion.h. |
|
||||||||||||
|
Definition at line 101 of file IdConversion.cxx.
00101 {
00102 s << (*(convers.m_op)) << std::endl << " Path: " << (*(convers.m_path)) <<
00103 " Condition: hasField " << (*(convers.m_condition));
00104 return s;
00105 }
|
|
|
Given an identifier in domain, convert if condition is satisfied.
Definition at line 75 of file IdConversion.h. Referenced by IdConversion(), and satisfies(). |
|
|
op knows how to do a conversion.
Definition at line 78 of file IdConversion.h. Referenced by buildOp(), IdConversion(), and internalConvert(). |
|
|
Defines domain of conversion.
Definition at line 72 of file IdConversion.h. |
1.2.13.1 written by Dimitri van Heesch,
© 1997-2001