xref: /aosp_15_r20/external/image_io/src/xml/xml_pi_rule.cc (revision ca0779eb572efbbfda2e47f806647c3c7eeea8c3)
1 #include "image_io/xml/xml_pi_rule.h"
2 
3 #include "image_io/xml/xml_handler.h"
4 #include "image_io/xml/xml_token_context.h"
5 
6 namespace photos_editing_formats {
7 namespace image_io {
8 
XmlPiRule()9 XmlPiRule::XmlPiRule() : XmlPiRule(kFirstStartPoint) {}
10 
XmlPiRule(XmlRule::StartPoint start_point)11 XmlPiRule::XmlPiRule(XmlRule::StartPoint start_point) : XmlRule("PI") {
12   // <? ... ?>
13   AddLiteralTerminal("<?");
14   AddThroughLiteralTerminal("?>").WithAction(
15       [&](const XmlActionContext& context) { return HandlePiValue(context); });
16   if (start_point == kSecondStartPoint) {
17     SetTerminalIndex(1);
18   }
19 }
20 
HandlePiValue(const XmlActionContext & context)21 DataMatchResult XmlPiRule::HandlePiValue(const XmlActionContext& context) {
22   XmlTokenContext token_context(context);
23   DataMatchResult result = context.GetHandler()->Pi(token_context);
24   return result;
25 }
26 
27 }  // namespace image_io
28 }  // namespace photos_editing_formats
29