Sync libimage_io to CL #222429857

- Update to match libdynamic_depth

Test: m image_io
Change-Id: I3496312b0e6c0159fb25d586cac772f847352379
diff --git a/METADATA b/METADATA
index e887ec6..33a5f87 100644
--- a/METADATA
+++ b/METADATA
@@ -7,11 +7,11 @@
     type: PIPER
     value: "http://google3/photos/editing/formats/image_io"
   }
-  version: "221162778"
+  version: "222429857"
   last_upgrade_date {
     year: 2018
     month: 11
-    day: 12
+    day: 21
   }
   license_type: NOTICE
 }
diff --git a/includes/image_io/extras/string_view_data_source.h b/includes/image_io/extras/string_view_data_source.h
deleted file mode 100644
index 0a90b44..0000000
--- a/includes/image_io/extras/string_view_data_source.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef IMAGE_IO_EXTRAS_STRING_VIEW_DATA_SOURCE_H_  // NOLINT
-#define IMAGE_IO_EXTRAS_STRING_VIEW_DATA_SOURCE_H_  // NOLINT
-
-#include "image_io/base/data_destination.h"
-#include "image_io/base/data_range.h"
-#include "image_io/base/data_segment_data_source.h"
-
-#include "third_party/absl/strings/string_view.h"
-
-namespace photos_editing_formats {
-namespace image_io {
-
-/// A DataSource that reads bytes from a string_view. The underlying string data
-/// must have a lifetime that exceeds the lifetime of this data source, and the
-/// string contents must not change while the data source is referencing it.
-class StringViewDataSource : public DataSegmentDataSource {
- public:
-  /// Constructs a StringViewDataSource using the given string_view.
-  /// @param str The string_view to read from.
-  explicit StringViewDataSource(absl::string_view string_src);
-
-  /// Returns the string view being used as the data source.
-  absl::string_view GetStringView() const { return string_src_; }
-
- private:
-  /// The string_view to read from.
-  absl::string_view string_src_;
-};
-
-}  // namespace image_io
-}  // namespace photos_editing_formats
-
-#endif // IMAGE_IO_EXTRAS_STRING_VIEW_DATA_SOURCE_H_  // NOLINT
diff --git a/includes/image_io/tools/image_tool_function.h b/includes/image_io/tools/image_tool_function.h
deleted file mode 100644
index f730359..0000000
--- a/includes/image_io/tools/image_tool_function.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef IMAGE_IO_TOOLS_IMAGE_TOOL_FUNCTION_H_  // NOLINT
-#define IMAGE_IO_TOOLS_IMAGE_TOOL_FUNCTION_H_  // NOLINT
-
-#include <functional>
-#include <string>
-
-namespace photos_editing_formats {
-namespace image_io {
-
-/// All output of the ImageTool() function and the underlying image_io functions
-/// are sent to this type of function that is passed to ImageTool(). Client code
-/// can use a function that writes the line to stdout or to a log file. The
-/// str parameter may have embedded new line characters in it. The function
-/// should not write its own new line at the end of the str.
-using ImageToolOutputter = std::function<void(const std::string& str)>;
-
-/// The ImageTool entry point, easily callable from a main() type function.
-/// @param argc The number of strings in the argv array.
-/// @param argv The options and values used in the command line.
-/// @param outputter A function to output the strings produced by ImageTool().
-/// @return A zero value for successful, non-zero for an error.
-int ImageTool(int argc, const char* argv[],
-              const ImageToolOutputter& outputter);
-
-}  // namespace image_io
-}  // namespace photos_editing_formats
-
-#endif // IMAGE_IO_TOOLS_IMAGE_TOOL_FUNCTION_H_  // NOLINT
diff --git a/includes/image_io/xml/xml_action.h b/includes/image_io/xml/xml_action.h
deleted file mode 100644
index dce6c7d..0000000
--- a/includes/image_io/xml/xml_action.h
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef IMAGE_IO_XML_XML_ACTION_H_  // NOLINT
-#define IMAGE_IO_XML_XML_ACTION_H_  // NOLINT
-
-#include <functional>
-
-#include "image_io/base/data_match_result.h"
-#include "image_io/xml/xml_handler_context.h"
-
-namespace photos_editing_formats {
-namespace image_io {
-
-class XmlActionContext;
-class XmlTerminal;
-
-/// The definition for an action function associated with an XmlTerminal.
-/// If the action does not need to change the result of the terminal, it can
-/// simply return the value from XmlActionContext::GetResult().
-using XmlAction =
-    std::function<DataMatchResult(const XmlActionContext& context)>;
-
-/// The data context passed from an XmlTerminal to its action function.
-class XmlActionContext : public XmlHandlerContext {
- public:
-  XmlActionContext(const XmlHandlerContext& context, XmlTerminal* terminal,
-                   const DataMatchResult& result)
-      : XmlHandlerContext(context), terminal_(terminal), result_(result) {}
-  XmlActionContext(size_t location, const DataRange& range,
-                   const DataSegment& segment, const DataLineMap& data_line_map,
-                   XmlHandler* handler, XmlTerminal* terminal,
-                   const DataMatchResult& result)
-      : XmlHandlerContext(location, range, segment, data_line_map, handler),
-        terminal_(terminal),
-        result_(result) {}
-
-  /// @return The terminal associated with the context.
-  XmlTerminal* GetTerminal() const { return terminal_; }
-
-  /// @return The result associated with the constext.
-  const DataMatchResult& GetResult() const { return result_; }
-
-  /// @param bytes_consumed The value to set in the returned result.
-  /// @return A result based on the context's action, but with its bytes
-  /// consumed value set to the given value.
-  DataMatchResult GetResultWithBytesConsumed(size_t bytes_consumed) const {
-    auto result = result_;
-    return result.SetBytesConsumed(bytes_consumed);
-  }
-
- private:
-  XmlTerminal* terminal_;
-  DataMatchResult result_;
-};
-
-}  // namespace image_io
-}  // namespace photos_editing_formats
-
-#endif // IMAGE_IO_XML_XML_ACTION_H_  // NOLINT
diff --git a/includes/image_io/xml/xml_attribute_rule.h b/includes/image_io/xml/xml_attribute_rule.h
deleted file mode 100644
index 564af07..0000000
--- a/includes/image_io/xml/xml_attribute_rule.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef IMAGE_IO_XML_XML_ATTRIBUTE_RULE_H_  // NOLINT
-#define IMAGE_IO_XML_XML_ATTRIBUTE_RULE_H_  // NOLINT
-
-#include "image_io/xml/xml_rule.h"
-
-namespace photos_editing_formats {
-namespace image_io {
-
-/// The XmlAttributeRule parses the following syntax:
-/// S? Name S? = S? 'Value'
-/// S? Name S? = S? "Value"
-class XmlAttributeRule : public XmlRule {
- public:
-  XmlAttributeRule();
-
- private:
-  /// Builds an XmlTokenContext from the XmlActionContext and calls the
-  /// handler's AttributeName() function.
-  /// @param context The action context from the name terminal.
-  /// @return The result value from the handler's function.
-  DataMatchResult HandleName(const XmlActionContext& context);
-
-  /// Builds an XmlTokenContext from the XmlActionContext and calls the
-  /// handler's AttributeValue() function.
-  /// @param context The action context from the quoted string terminal.
-  /// @return The result value from the handler's function.
-  DataMatchResult HandleValue(const XmlActionContext& context);
-};
-
-}  // namespace image_io
-}  // namespace photos_editing_formats
-
-#endif // IMAGE_IO_XML_XML_ATTRIBUTE_RULE_H_  // NOLINT
diff --git a/includes/image_io/xml/xml_cdata_and_comment_rules.h b/includes/image_io/xml/xml_cdata_and_comment_rules.h
deleted file mode 100644
index 0cc2e50..0000000
--- a/includes/image_io/xml/xml_cdata_and_comment_rules.h
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef IMAGE_IO_XML_XML_CDATA_AND_COMMENT_RULES_H_  // NOLINT
-#define IMAGE_IO_XML_XML_CDATA_AND_COMMENT_RULES_H_  // NOLINT
-
-#include "image_io/xml/xml_rule.h"
-
-namespace photos_editing_formats {
-namespace image_io {
-
-/// The XmlCdataRule parses the following syntax "<![CDATA[ ... ]]>".
-/// As mentioned in the comments for the XmlHandler::Cdata() function, the token
-/// value that is passed to the handler never includes the leading "<![CDATA["
-/// syntax and always includes the trailing "]]>" syntax. This considerably
-/// simplifies the parsing task. The alternate start point constructor is used
-/// by the XmlCdataOrCommentRule.
-class XmlCdataRule : public XmlRule {
- public:
-  XmlCdataRule();
-  explicit XmlCdataRule(StartPoint start_point);
-
- private:
-  /// Builds an XmlTokenContext from the XmlActionContext and calls the
-  /// handler's Cdata() function.
-  /// @param context The action context from the rule's terminal.
-  /// @return The result value from the handler's function.
-  DataMatchResult HandleCdataValue(const XmlActionContext& context);
-};
-
-/// The XmlCommentRule parses the following syntax "<!-- ... -->".
-/// As mentioned in the comments for the XmlHandler::Comment() function, the
-/// token value that is passed to the handler never includes the leading "<!--"
-/// syntax and always includes the trailing "-->" syntax. This considerably
-/// simplifies the parsing task.  The alternate start point constructor is used
-/// by the XmlCdataOrCommentRule.
-class XmlCommentRule : public XmlRule {
- public:
-  XmlCommentRule();
-  explicit XmlCommentRule(StartPoint start_point);
-
- private:
-  /// Builds an XmlTokenContext from the XmlActionContext and calls the
-  /// handler's Comment() function.
-  /// @param context The action context from the rule's terminal.
-  /// @return The result value from the handler's function.
-  DataMatchResult HandleCommentValue(const XmlActionContext& context);
-};
-
-/// This rule will use chain delegation to start either the XmlCdataRule or the
-/// XmlCommentRule, depending on the text being parsed. The syntax for XML is
-/// pretty poor here - the parser needs to look ahead two characters from the <
-/// character to determine what to do.  The alternate start point constructor is
-/// used by the XmlElementContentRule.
-class XmlCdataOrCommentRule : public XmlRule {
- public:
-  XmlCdataOrCommentRule();
-  explicit XmlCdataOrCommentRule(StartPoint start_point);
-
- private:
-  /// Builds an XmlTokenContext from the XmlActionContext and creates the
-  /// XmlCdataRule or XmlCommentRule to chain to depending on what character
-  /// follows the exclamation point of the "<!" syntax.
-  /// @param context The action context from the rule's terminal.
-  /// @return The result value from the action context.
-  DataMatchResult HandlePostBangChar(const XmlActionContext& context);
-};
-
-}  // namespace image_io
-}  // namespace photos_editing_formats
-
-#endif // IMAGE_IO_XML_XML_CDATA_AND_COMMENT_RULES_H_  // NOLINT
diff --git a/includes/image_io/xml/xml_element_rules.h b/includes/image_io/xml/xml_element_rules.h
deleted file mode 100644
index f40f370..0000000
--- a/includes/image_io/xml/xml_element_rules.h
+++ /dev/null
@@ -1,92 +0,0 @@
-#ifndef IMAGE_IO_XML_XML_ELEMENT_RULES_H_  // NOLINT
-#define IMAGE_IO_XML_XML_ELEMENT_RULES_H_  // NOLINT
-
-#include "image_io/xml/xml_rule.h"
-
-namespace photos_editing_formats {
-namespace image_io {
-
-/// The XmlElementRule parses the following syntax:
-/// Element ::= EmptyElemTag  | STag content ETag
-/// EmptyElemTag ::=  '<' Name (S Attribute)* S? '/>'
-/// STag         ::=  '<' Name (S Attribute)* S? '>'
-/// ETag         ::=  '</' Name S? '>'
-/// The Attribute syntax is parsed by XmlAttributeRule, which this rule
-/// delegates to as a child rule. The EmptyElemTag type syntax is handled by
-/// this rule. The STag part of the syntax is handled by this rule, but the
-/// element contents and the ETag syntax is handled by the XmlElementContentRule
-/// that is chained to by this rule.
-class XmlElementRule : public XmlRule {
- public:
-  XmlElementRule();
-  explicit XmlElementRule(StartPoint start_point);
-
- private:
-  /// Builds an XmlTokenContext from the XmlActionContext and calls the
-  /// handler's StartElement() function.
-  /// @param context The action context from the rule's terminal.
-  /// @return The result value from the handler's function.
-  DataMatchResult HandleName(const XmlActionContext& context);
-
-  /// Handles the book keeping after parsing the whitespace following the name
-  /// of the element, basically looking ahead to see if an XmlAttributeRule has
-  /// to be delegated to as a child rule, or if the element ends.
-  /// @param context The action context from the rule's terminal.
-  /// @return The result value action context.
-  DataMatchResult HandlePostWhitespaceChar(const XmlActionContext& context);
-
-  /// Builds an XmlTokenContext from the XmlActionContext and calls the
-  /// handler's FinishElement() function in response to the final literal in
-  /// the EmptyElemTag type sytax. As written in the comment for the XmlHandler
-  /// FinishElement() function, the token context passed to the handler in this
-  /// case will have an invalid range and a XmlPortion value of kNone - i.e.,
-  /// the element name is not available tfor this form of the element syntax.
-  /// @param context The action context from the rule's terminal.
-  /// @return The result value from the handler's function.
-  DataMatchResult HandleEmptyElemTagEnd(const XmlActionContext& context);
-
-  /// Handles the book keeping after parsing the final ">" literal of the STag
-  /// syntax of the rule, creating an XmlElementContentRule for use as a chained
-  /// to rule.
-  /// @param context The action context from the rule's terminal.
-  /// @return The result value action context.
-  DataMatchResult HandleSTagEnd(const XmlActionContext& context);
-};
-
-/// The XmlElementContentRule parses the following syntax:
-/// (c? Element | PI | CDATA | Comment )+ ETag
-/// The "c?" syntax represents the character data passed to the XmlHandler's
-/// ElementContent() function. The syntax for Element, PI, CDATA and Comment
-/// all cause a child rule to be created and delegated to. The ETag syntax will
-/// cause this element to be finished with a DataMatchResult type of kFull.
-class XmlElementContentRule : public XmlRule {
- public:
-  XmlElementContentRule();
-
- private:
-  /// Builds an XmlTokenContext from the XmlActionContext and calls the
-  /// handler's ElementContent() function.
-  /// @param context The action context from the rule's terminal.
-  /// @return The result value from the handler's function.
-  DataMatchResult HandleContent(const XmlActionContext& context);
-
-  /// Handles the book keeping after parsing the element's content characters,
-  /// and the first character literal ("<") of the Element, PI, CDATA or Comment
-  /// syntax, creating an appropriate child rule to delegate the processing to.
-  /// @param context The action context from the rule's terminal.
-  /// @return The result value action context.
-  DataMatchResult HandlePostOpenChar(const XmlActionContext& context);
-
-  /// Builds an XmlTokenContext from the XmlActionContext and calls the
-  /// handler's FinishElement() function. No check is done by the rule to verify
-  /// that the element name matches the one that was passed to the handler's
-  /// StartElement.
-  /// @param context The action context from the rule's terminal.
-  /// @return The result value from the handler's function.
-  DataMatchResult HandleEndTag(const XmlActionContext& context);
-};
-
-}  // namespace image_io
-}  // namespace photos_editing_formats
-
-#endif // IMAGE_IO_XML_XML_ELEMENT_RULES_H_  // NOLINT
diff --git a/includes/image_io/xml/xml_handler.h b/includes/image_io/xml/xml_handler.h
deleted file mode 100644
index cdf3d30..0000000
--- a/includes/image_io/xml/xml_handler.h
+++ /dev/null
@@ -1,107 +0,0 @@
-#ifndef IMAGE_IO_XML_XML_HANDLER_H_  // NOLINT
-#define IMAGE_IO_XML_XML_HANDLER_H_  // NOLINT
-
-#include "image_io/base/data_match_result.h"
-#include "image_io/xml/xml_token_context.h"
-
-namespace photos_editing_formats {
-namespace image_io {
-
-/// The handler that is called by XmlRule instances as they parse XML syntax
-/// and produce tokens defined in the XmlTokenContext. Each handler function
-/// may be called multiple times with different XmlPortion values. The first
-/// time the XmlPortion::kBegin bit will be set. The last time, XmlPortion::kEnd
-/// will be set. In between, XmlPortion::kMiddle will be set. If the entire
-/// token value is available for the handler, all three bits will be set.
-/// The implementation of each function in this base class returns the
-/// DataMatchResult value that the context provides. The function overrides in
-/// subclasses can return the same context value, or a copy that is modified
-/// with a different result type, message and "can continue" flag.
-class XmlHandler {
- public:
-  virtual ~XmlHandler() = default;
-
-  /// This function is called to start an XML element. Once started, any of
-  /// the other handler functions may be called.
-  /// @param context The token context used to specify the element name.
-  /// @return The match result from the context, or one that is modified to
-  /// contain an error message if needed.
-  virtual DataMatchResult StartElement(const XmlTokenContext& context);
-
-  /// This function is called to finish an XML element. Each call to this
-  /// function should be paired with a call to a StartElement function.
-  /// @param context The token context used to obtain the match result for
-  /// returning. For this function, the context might not have a valid token
-  /// value: the XmlPortion will always be kNone and the token range invalid.
-  /// This is the case if the syntax parsed is an empty element like this:
-  /// "<SomeElement [Attribute=Name]... />". For non empty elements with syntax:
-  /// "<SomeElement>...</SomeElement>", the value will be the element name.
-  /// @return The match result from the context, or one that is modified to
-  /// contain an error message if needed.
-  virtual DataMatchResult FinishElement(const XmlTokenContext& context);
-
-  /// This function is called to define an attribute name. This function will
-  /// never be called unless an element has been started with a prior call to
-  /// the StartElement() function.
-  /// @param context The token context used to specify the attribute name.
-  /// @return The match result from the context, or one that is modified to
-  /// contain an error message if needed.
-  virtual DataMatchResult AttributeName(const XmlTokenContext& context);
-
-  /// This function is called to define an attribute value. The token value
-  /// passed to this function always includes the quote marks at the begin and
-  /// end of the token value. The quote marks always match and may be either a
-  /// single quote (') or a double quote ("). Sometimes attribute values can be
-  /// very long, so implementations of this function should use care if they
-  /// retain the value as a string for later processing. This function will
-  /// never be called unless an element has been started with a prior call to
-  /// the StartElement() and AttributeName() functions.
-  /// @param context The token context used to specify the attribute value.
-  /// @return The match result from the context, or one that is modified to
-  /// contain an error message if needed.
-  virtual DataMatchResult AttributeValue(const XmlTokenContext& context);
-
-  /// This function is called to define a block of characters in the body of
-  /// an element. This function may be called multiple times for a given
-  /// element. Handlers that are interested in the character content for an
-  /// element should concatenate the token values from all calls to obtain the
-  /// full value for the element.
-  /// @param context The token context used to specify the content value.
-  /// @return The match result from the context, or one that is modified to
-  /// contain an error message if needed.
-  virtual DataMatchResult ElementContent(const XmlTokenContext& context);
-
-  /// This function is called to inform the handler of a comment. A comment in
-  /// XML has the syntax "<!--...-->". In order to simplify the XML parsing
-  /// task, the tokens passed to this function never include the leading "<!--"
-  /// characters, but always include the trailing "-->".
-  /// @param context The token context used to specify the comment.
-  /// @return The match result from the context, or one that is modified to
-  /// contain an error message if needed.
-  virtual DataMatchResult Comment(const XmlTokenContext& context);
-
-  /// This function is called to inform the handler CDATA block. A CDATA block
-  /// in XML has the syntax "<![CDATA[...]]>". In order to simplify the XML
-  /// parsing task, the tokens passed to this function never include the leading
-  /// "<![CDATA[" characters, but always include the trailing "]]".
-  /// @param context The token context used to specify the CDATA block.
-  /// @return The match result from the context, or one that is modified to
-  /// contain an error message if needed.
-  virtual DataMatchResult Cdata(const XmlTokenContext& context);
-
-  /// This function is called to define a processing instruction. Processing
-  /// instructions have an XML syntax "<?...?>". In order to simplify the XML
-  /// parsing task, no parsing of the processing instruction is done: handlers
-  /// that need the contents parsed are on their own. Also, again to simplify
-  /// the XML parsing task, the tokens passed to this function never include the
-  /// leading "<?" characters, but always include the trailing "?>".
-  /// @param context The token context used to specify the processing data.
-  /// @return The match result from the context, or one that is modified to
-  /// contain an error message if needed.
-  virtual DataMatchResult Pi(const XmlTokenContext& context);
-};
-
-}  // namespace image_io
-}  // namespace photos_editing_formats
-
-#endif // IMAGE_IO_XML_XML_HANDLER_H_  // NOLINT
diff --git a/includes/image_io/xml/xml_handler_context.h b/includes/image_io/xml/xml_handler_context.h
deleted file mode 100644
index 5595118..0000000
--- a/includes/image_io/xml/xml_handler_context.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef IMAGE_IO_XML_XML_HANDLER_CONTEXT_H_  // NOLINT
-#define IMAGE_IO_XML_XML_HANDLER_CONTEXT_H_  // NOLINT
-
-#include "image_io/base/data_context.h"
-
-namespace photos_editing_formats {
-namespace image_io {
-
-class XmlHandler;
-
-class XmlHandlerContext : public DataContext {
- public:
-  XmlHandlerContext(const DataContext& context, XmlHandler* handler)
-      : DataContext(context), handler_(handler) {}
-
-  XmlHandlerContext(size_t location, const DataRange& range,
-                    const DataSegment& segment,
-                    const DataLineMap& data_line_map, XmlHandler* handler)
-      : DataContext(location, range, segment, data_line_map),
-        handler_(handler) {}
-
-  XmlHandler* GetHandler() const { return handler_; }
-
- private:
-  XmlHandler* handler_;
-};
-
-}  // namespace image_io
-}  // namespace photos_editing_formats
-
-#endif // IMAGE_IO_XML_XML_HANDLER_CONTEXT_H_  // NOLINT
diff --git a/includes/image_io/xml/xml_pi_rule.h b/includes/image_io/xml/xml_pi_rule.h
deleted file mode 100644
index 674a3fa..0000000
--- a/includes/image_io/xml/xml_pi_rule.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef IMAGE_IO_XML_XML_PI_RULE_H_  // NOLINT
-#define IMAGE_IO_XML_XML_PI_RULE_H_  // NOLINT
-
-#include "image_io/xml/xml_rule.h"
-
-namespace photos_editing_formats {
-namespace image_io {
-
-/// The XmlPiRule parses the processing information syntax: "<?...?>". This
-/// syntax is considerably simplified from the official XML specification. As
-/// documented in the comments for the XmlHandler Pi() function, The leading
-/// "<?" syntax is never sent to the handler, while the trailing "?>" literal
-/// is always sent as part of the processing content token. This approach makes
-/// it much easier to parse XML syntax. The alternate start point constructor
-/// is used by the XmlElementContentRule.
-class XmlPiRule : public XmlRule {
- public:
-  XmlPiRule();
-  explicit XmlPiRule(StartPoint start_point);
-
- private:
-  /// Builds an XmlTokenContext from the XmlActionContext and calls the
-  /// handler's Pi() function.
-  /// @param context The action context from the rule's terminal.
-  /// @return The result value from the handler's function.
-  DataMatchResult HandlePiValue(const XmlActionContext& context);
-};
-
-}  // namespace image_io
-}  // namespace photos_editing_formats
-
-#endif // IMAGE_IO_XML_XML_PI_RULE_H_  // NOLINT
diff --git a/includes/image_io/xml/xml_portion.h b/includes/image_io/xml/xml_portion.h
deleted file mode 100644
index 673c958..0000000
--- a/includes/image_io/xml/xml_portion.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef IMAGE_IO_XML_XML_PORTION_H_  // NOLINT
-#define IMAGE_IO_XML_XML_PORTION_H_  // NOLINT
-
-namespace photos_editing_formats {
-namespace image_io {
-
-/// An bit-type enum for indicating what part of an entity is defined: the
-/// begin, middle and or end. Bitwise "and" and "or" operators are defined to
-/// combine and test values.
-enum class XmlPortion {
-  kNone = 0,
-  kBegin = 1,
-  kMiddle = 2,
-  kEnd = 4,
-};
-
-/// @return The value that results from the bitwise "and" of given portions.
-inline XmlPortion operator&(XmlPortion lhs, XmlPortion rhs) {
-  int lhs_value = static_cast<int>(lhs);
-  int rhs_value = static_cast<int>(rhs);
-  return static_cast<XmlPortion>(lhs_value & rhs_value);
-}
-
-/// @return The value that results from the bitwise "or"  of given portions.
-inline XmlPortion operator|(XmlPortion lhs, XmlPortion rhs) {
-  int lhs_value = static_cast<int>(lhs);
-  int rhs_value = static_cast<int>(rhs);
-  return static_cast<XmlPortion>(lhs_value | rhs_value);
-}
-
-/// @param value The value to use for the test.
-/// @param mask The mask to use for the test.
-/// @return Whether any of the bits in the mask are set in the value.
-inline bool ContainsAny(XmlPortion value, XmlPortion mask) {
-  return (value & mask) != XmlPortion::kNone;
-}
-
-/// @param value The value to use for the test.
-/// @param mask The mask to use for the test.
-/// @return Whether all of the bits in the mask are set in the value.
-inline bool ContainsAll(XmlPortion value, XmlPortion mask) {
-  return (value & mask) == mask;
-}
-
-}  // namespace image_io
-}  // namespace photos_editing_formats
-
-#endif // IMAGE_IO_XML_XML_PORTION_H_  // NOLINT
diff --git a/includes/image_io/xml/xml_reader.h b/includes/image_io/xml/xml_reader.h
deleted file mode 100644
index 9a42b74..0000000
--- a/includes/image_io/xml/xml_reader.h
+++ /dev/null
@@ -1,105 +0,0 @@
-#ifndef IMAGE_IO_XML_XML_READER_H_  // NOLINT
-#define IMAGE_IO_XML_XML_READER_H_  // NOLINT
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "image_io/base/data_line_map.h"
-#include "image_io/base/data_match_result.h"
-#include "image_io/base/message.h"
-#include "image_io/xml/xml_handler_context.h"
-#include "image_io/xml/xml_rule.h"
-
-namespace photos_editing_formats {
-namespace image_io {
-
-/// A class for reading and parsing the text of a data segment, resulting in the
-/// functions of an XmlHandler to be called. This reader's Parse() function can
-/// be called multiple times for text that spans multiple data segments. Errors
-/// are reported to the message handler as they are encountered. In general,
-/// there will be three types of errors: internal (programming), syntax, and
-/// value errors. Internal errors can come from any where in this code base;
-/// Only one such error is permitted per StartParse/Parse... sequence. Syntax
-/// errors are usually issued by XmlRule instances; like internal errors, only
-/// one such error is tolerated per StartParse/Parse... sequence. XmlHandler
-/// functions may issue value errors; multiple such value errors are tolerated.
-class XmlReader {
- public:
-  explicit XmlReader(XmlHandler* handler)
-      : handler_(handler),
-        bytes_parsed_(0),
-        has_internal_or_syntax_error_(false),
-        has_errors_(false) {}
-
-  /// Sets up the reader for parsing data segment text using the given XmlRule.
-  /// @param rule The top level rule to use when parsing the data segment text.
-  /// @return Whether the reader was set up propertly.
-  bool StartParse(std::unique_ptr<XmlRule> rule);
-
-  /// Parses the text portion of the data segment starting at a location. This
-  /// function may be called multiple times for text that spans multiple data
-  /// segments.
-  /// @param start_location The location at which to start reading/parsing.
-  /// This location must be contained in the range parameter.
-  /// @param range The portion of the data segment to parse. This range value
-  /// must be contained in the range returned by DataSegment::GetRange()
-  /// @param segment The segment containing the text to parse.
-  /// @return Whether the parsing was successful.
-  bool Parse(size_t start_location, const DataRange& range,
-             const DataSegment& segment);
-
-  /// Finishes up the reading/parsing process. The rule passed to StartParse()
-  /// must have consumed all the text of the segments and be "done", otherwise
-  /// this function will issue an error message.
-  /// @param Whether the reading/parsing operation was completed successfully.
-  bool FinishParse();
-
-  /// @return The total number of bytes of text that have been read/parsed.
-  size_t GetBytesParsed() const { return bytes_parsed_; }
-
-  /// @return Whether errors have been encountered in reading/parsing the text.
-  bool HasErrors() const { return has_errors_; }
-
-  /// @return The handler that handles the output of the parsing operations.
-  XmlHandler* GetHandler() const { return handler_; }
-
- private:
-  /// Sets up the context's name list that is used when creating error message.
-  /// @parma context The context to set up.
-  void InitializeContextNameList(XmlHandlerContext* context);
-
-  /// Reports the message indicated in the result to the message handler and
-  /// updates the data boolean data members indicating errors.
-  /// @param result The result value for an XmlRule::Parse function.
-  /// @param context The context for generating an error message if needed.
-  void ReportError(const DataMatchResult& result, const DataContext& context);
-
-  /// Reports the message to the message handler and updates the data boolean
-  /// data members indicating errors.
-  /// @param message The message to send to the message handler.
-  void ReportError(const Message& message);
-
-  /// The reader's handler.
-  XmlHandler* handler_;
-
-  /// A data line map used for error message creation.
-  DataLineMap data_line_map_;
-
-  /// The pending and active rules.
-  std::vector<std::unique_ptr<XmlRule>> rule_stack_;
-
-  /// The total number of bytes that have been parsed.
-  size_t bytes_parsed_;
-
-  /// Whether an internal or syntax error has occurred.
-  bool has_internal_or_syntax_error_;
-
-  /// Whether any type of error has occurred.
-  bool has_errors_;
-};
-
-}  // namespace image_io
-}  // namespace photos_editing_formats
-
-#endif // IMAGE_IO_XML_XML_READER_H_  // NOLINT
diff --git a/includes/image_io/xml/xml_rule.h b/includes/image_io/xml/xml_rule.h
deleted file mode 100644
index c76f87c..0000000
--- a/includes/image_io/xml/xml_rule.h
+++ /dev/null
@@ -1,175 +0,0 @@
-#ifndef IMAGE_IO_XML_XML_RULE_H_  // NOLINT
-#define IMAGE_IO_XML_XML_RULE_H_  // NOLINT
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "image_io/base/data_match_result.h"
-#include "image_io/xml/xml_handler_context.h"
-#include "image_io/xml/xml_terminal.h"
-
-namespace photos_editing_formats {
-namespace image_io {
-
-/// A rule represents a sequence of terminals to match text from a DataSource,
-/// and the state needed to keep track the parsing operation in case the text
-/// is split across multiple DataSegments. XmlRules collaborate with an instance
-/// of XmlHandler to process the token values the terminals produce.
-///
-/// Terminals are added in the constructors of the rule subclasses, and are
-/// not typically accessed directly from the clients of an XmlRule. Instead,
-/// XmlRule clients normally just call the rule's Parse function and take action
-/// based on the DataMatchResult value that is returned. The functions of the
-/// XmlHandler are called internally by the rule's terminals as they parse the
-/// text in the data segment.
-///
-/// Normally, the terminals are parsed by the Parse() function in a sequential
-/// manner until they are exhausted. At which time the Parse function returns
-/// with a DataMatchResult that has a type equal to kFull. If the DataSegment
-/// runs out of data before the end of the final terminal, the result type will
-/// be kPartialOutOfData. Of course if any of the terminals' scanners detect an
-/// error the result type will be kError.
-///
-/// Rules may decide to delegate the parsing process to another rule. There are
-/// two types of delegation:
-/// 1. Rule chaining - in this case a rule decides that another rule should
-///    be used instead to continue the parsing process. This situation is
-///    indicated when the result type is kFull and the rule's HasNextRule()
-///    function returns true. The chained-to rule is obtained by calling the
-///    rule's GetNextRule() function. The current rule can be discarded.
-/// 2. Child rules - in this case a "parent" rule decides that the next set of
-///    syntax should be parsed by another "child" rule, and after that rule
-///    completes, the parsing task should be returned to the parent rule. This
-///    situaltion is indicated when the result type is kPartial and the rule's
-///    HasNextRule() returns true. The child rule is obtained by calling the
-///    rule's GetNextRule() function. The current parent rule should be placed
-///    on a stack until the child rule is done, and then the child discarded and
-///    the parent rule used for the next Parse operation.
-/// The action functions associated with a terminal are typically used to create
-/// the next rule and set the result type and thus initiate the delegation
-/// process. When the XmlRule::Parse function detects a delegation has been
-/// requested, it returns to its caller so that the caller can handle the
-/// delegation in the appropriate fashion. For an example, see the XmlReader's
-/// Parse() function.
-///
-/// In addition to delegation the action functions associated with a terminal
-/// can change the order of the terminals processed from a strictly sequential
-/// order to whatever the rule so desires. This is done by calling the rule's
-/// SetTerminalIndex() function. Terminals can be identified by name using the
-/// GetTerminalIndexFromName() function if the rule's terminals were
-/// constructed with names.  If the terminal index of a rule is set to a
-/// terminal that has already been used, the terminal's scanners state must be
-/// reset in order for it to parse successfully again.  Sometimes the entire
-/// rule is "restarted" in which case the ResetTerminalScanners() function can
-/// be called to reset the scanners of all the rules terminals.
-///
-/// Finally, because of the look-ahead needs of the XML grammar, some rules
-/// support alternate "starting points", allowing them to skip some set of
-/// initial terminals when the rule's Parse() function is called. Rules that
-/// support this feature will have a constructor with an StartPoint parameter.
-class XmlRule {
- public:
-  /// For rules that support alternate starting points, this enum provides the
-  /// values at which a rule's Parse() function can begin.
-  enum StartPoint {
-    /// Start parsing at the first terminal position.
-    kFirstStartPoint,
-
-    /// STart parsing at a second (alternative) position.
-    kSecondStartPoint,
-  };
-
-  virtual ~XmlRule() = default;
-  explicit XmlRule(const std::string& name);
-
-  /// @return The name of the rule.
-  const std::string& GetName() const { return name_; }
-
-  /// Parse the text indicated in the context's data segment and range and call
-  /// the context's XmlHandler functions as needed. The implementation of this
-  /// function makes use of the terminals contained by the rule, but it is
-  /// declared virtual so that subclasses can customize as needed.
-  /// @param context The context describing the text to parse and the handler
-  /// to call.
-  /// @param A result that indicates the type of match that occurred, the number
-  /// of bytes consumed and an error message if needed.
-  virtual DataMatchResult Parse(XmlHandlerContext context);
-
-  /// Adds a literal terminal to the rule.
-  /// @param literal The literal value to scan for.
-  /// @return The terminal, enabling direct calls to WithName()/WithAction().
-  XmlTerminal& AddLiteralTerminal(const std::string& literal);
-
-  /// Adds a name terminal to the rule.
-  /// @return The terminal, enabling direct calls to WithName()/WithAction().
-  XmlTerminal& AddNameTerminal();
-
-  /// Adds a quoted string terminal to the rule.
-  /// @return The terminal, enabling direct calls to WithName()/WithAction().
-  XmlTerminal& AddQuotedStringTerminal();
-
-  /// Adds a sentinel terminal to the rule.
-  /// @param sentinels The sentinel values to scan for.
-  /// @return The terminal, enabling direct calls to WithName()/WithAction().
-  XmlTerminal& AddSentinelTerminal(const std::string& sentinels);
-
-  /// Adds a scan through literal terminal to the rule.
-  /// @param literal The literal value to scan through.
-  /// @return The terminal, enabling direct calls to WithName()/WithAction().
-  XmlTerminal& AddThroughLiteralTerminal(const std::string& literal);
-
-  /// Adds a whitespace terminal to the rule.
-  /// @return The terminal, enabling direct calls to WithName()/WithAction().
-  XmlTerminal& AddWhitespaceTerminal();
-
-  /// Adds an optional whitespace terminal to the rule.
-  /// @return The terminal, enabling direct calls to WithName()/WithAction().
-  XmlTerminal& AddOptionalWhitespaceTerminal();
-
-  /// @return The number of terminals in the rule.
-  size_t GetTerminalCount() const { return terminals_.size(); }
-
-  /// @return The index of the terminal currently parsing text.
-  size_t GetTerminalIndex() const { return terminal_index_; }
-
-  /// @param name The name of the terminal to look for.
-  /// @return The index of the terminal with the given name, or the value
-  /// returned by the rule's GetTerminalCount() if not found.
-  size_t GetTerminalIndexFromName(const std::string name) const;
-
-  /// @param terminal_index The index of the terminal that should next be used
-  /// for parsing the input text.
-  void SetTerminalIndex(size_t terminal_index);
-
-  /// @return The terminal currently parsing text, or nullptr if there is none.
-  XmlTerminal* GetCurrentTerminal();
-
-  /// @param index The index of the terminal to get.
-  /// @return The terminal at the given index, or nullptr if index is invalid.
-  XmlTerminal* GetTerminal(size_t index);
-
-  /// Resets the scanner's state of all the terminals in the rule.
-  void ResetTerminalScanners();
-
-  /// @return Whether the rule has a next rule for delegation.
-  bool HasNextRule() const;
-
-  /// @return Returns the next rule to the caller. If there is no next rule,
-  /// the get function of the returned unique_ptr will return nullptr.
-  std::unique_ptr<XmlRule> ReleaseNextRule();
-
-  /// @param next_rule The new rule to use for delegation purposes.
-  void SetNextRule(std::unique_ptr<XmlRule> next_rule);
-
- private:
-  std::string name_;
-  std::vector<XmlTerminal> terminals_;
-  std::unique_ptr<XmlRule> next_rule_;
-  size_t terminal_index_;
-};
-
-}  // namespace image_io
-}  // namespace photos_editing_formats
-
-#endif // IMAGE_IO_XML_XML_RULE_H_  // NOLINT
diff --git a/includes/image_io/xml/xml_terminal.h b/includes/image_io/xml/xml_terminal.h
deleted file mode 100644
index 7d999f0..0000000
--- a/includes/image_io/xml/xml_terminal.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef IMAGE_IO_XML_XML_TERMINAL_H_  // NOLINT
-#define IMAGE_IO_XML_XML_TERMINAL_H_  // NOLINT
-
-#include <string>
-
-#include "image_io/base/data_scanner.h"
-#include "image_io/xml/xml_action.h"
-#include "image_io/xml/xml_token_context.h"
-
-namespace photos_editing_formats {
-namespace image_io {
-
-/// A terminal represents a part of a rule that uses a DataScanner to match
-/// zero or more characters from a DataSource. A terminal can also have a name
-/// that can be be used in error messages and also used to identify it in a
-/// rule. A terminal can also have an action function associated with it that it
-/// can use to validate the token produced by the terminal/scanner, and do
-/// further processing with the token. Finally, the terminal's action function
-/// can manipulate the DataMatchResult that was produced by the terminal's
-/// scanner and accessible via the action function's XmlActionContext param.
-class XmlTerminal {
- public:
-  explicit XmlTerminal(const DataScanner& scanner) : scanner_(scanner){}
-
-  /// Sets the name of the terminal. Looks best with an XmlRule::AddTerminal
-  /// function: AddWhitespaceTerminal().WithName("SomeName");
-  /// @param name The name to give to the terminal.
-  /// @return A reference to the terminal.
-  XmlTerminal& WithName(const std::string& name) {
-    name_ = name;
-    return *this;
-  }
-
-  /// Sets the action of the terminal. Looks best with an XmlRule::AddTerminal
-  /// function: AddWhitespaceTerminal().WithAction(SomeAction);
-  /// @param action The action to give to the terminal.
-  /// @return A reference to the terminal.
-  XmlTerminal& WithAction(const XmlAction& action) {
-    action_ = action;
-    return *this;
-  }
-
-  /// @return The terminal's scanner.
-  DataScanner* GetScanner() { return &scanner_; }
-
-  /// @return The terminal's name.
-  const std::string& GetName() const { return name_; }
-
-  /// @return The terminal's action function.
-  const XmlAction& GetAction() const { return action_; }
-
- private:
-  DataScanner scanner_;
-  XmlAction action_;
-  std::string name_;
-};
-
-}  // namespace image_io
-}  // namespace photos_editing_formats
-
-#endif // IMAGE_IO_XML_XML_TERMINAL_H_  // NOLINT
diff --git a/includes/image_io/xml/xml_token_context.h b/includes/image_io/xml/xml_token_context.h
deleted file mode 100644
index cceca5c..0000000
--- a/includes/image_io/xml/xml_token_context.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef IMAGE_IO_XML_XML_TOKEN_CONTEXT_H_  // NOLINT
-#define IMAGE_IO_XML_XML_TOKEN_CONTEXT_H_  // NOLINT
-
-#include <string>
-
-#include "image_io/base/data_context.h"
-#include "image_io/base/data_match_result.h"
-#include "image_io/base/data_range.h"
-#include "image_io/xml/xml_portion.h"
-
-namespace photos_editing_formats {
-namespace image_io {
-
-class XmlActionContext;
-
-/// A token context is passed from the action of an XmlTerminal to an XmlHandler
-/// associated with the XmlActionContext used to call the action function.
-class XmlTokenContext : public DataContext {
- public:
-  explicit XmlTokenContext(const XmlActionContext& context);
-  XmlTokenContext(size_t location, const DataRange& range,
-                  const DataSegment& segment, const DataLineMap& data_line_map,
-                  const DataMatchResult& result, const DataRange& token_range,
-                  const XmlPortion& token_portion);
-
-  /// @return The result associated with the context.
-  const DataMatchResult& GetResult() const { return result_; }
-
-  /// @return The token range for the token. Note that the token range may not
-  /// be a subrange of the context's GetRange() or even the context's segment's
-  /// data range. Such would be the case when a token's value is split across
-  /// two or more data segments.
-  const DataRange& GetTokenRange() const { return token_range_; }
-
-  /// @return The portion of the token that this context represents. This
-  /// portion value can be the bitwise or of any of the XmlPortion bit values.
-  const XmlPortion& GetTokenPortion() const { return token_portion_; }
-
-  /// Builds the string value of the token. If the context's token portion has
-  /// the XmlPortion::kBegin bit set, the string value is first cleared. Then
-  /// the string is extracted from the context's data source and appended onto
-  /// the value. Remember that some token values (especially attribute values)
-  /// can be quite long so care should be excercised when obtaining values with
-  /// this function.
-  /// @param value The value of the token being built.
-  /// @return Whether the token value is complete (i.e., the context's portion
-  /// had the XmlPortion::kEnd bit set).
-  bool BuildTokenValue(std::string* value) const;
-
-  static XmlPortion ComputeTokenPortion(size_t token_scan_count,
-                                        DataMatchResult::Type result_type);
-
- private:
-  DataMatchResult result_;
-  DataRange token_range_;
-  XmlPortion token_portion_;
-};
-
-}  // namespace image_io
-}  // namespace photos_editing_formats
-
-#endif // IMAGE_IO_XML_XML_TOKEN_CONTEXT_H_  // NOLINT