diff options
Diffstat (limited to 'src/xml/xml_pi_rule.cc')
-rw-r--r-- | src/xml/xml_pi_rule.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/xml/xml_pi_rule.cc b/src/xml/xml_pi_rule.cc new file mode 100644 index 0000000..071b8fd --- /dev/null +++ b/src/xml/xml_pi_rule.cc @@ -0,0 +1,28 @@ +#include "image_io/xml/xml_pi_rule.h" + +#include "image_io/xml/xml_handler.h" +#include "image_io/xml/xml_token_context.h" + +namespace photos_editing_formats { +namespace image_io { + +XmlPiRule::XmlPiRule() : XmlPiRule(kFirstStartPoint) {} + +XmlPiRule::XmlPiRule(XmlRule::StartPoint start_point) : XmlRule("PI") { + // <? ... ?> + AddLiteralTerminal("<?"); + AddThroughLiteralTerminal("?>").WithAction( + [&](const XmlActionContext& context) { return HandlePiValue(context); }); + if (start_point == kSecondStartPoint) { + SetTerminalIndex(1); + } +} + +DataMatchResult XmlPiRule::HandlePiValue(const XmlActionContext& context) { + XmlTokenContext token_context(context); + DataMatchResult result = context.GetHandler()->Pi(token_context); + return result; +} + +} // namespace image_io +} // namespace photos_editing_formats |