AAPT2: Add Inline Complex XML support
See: https://developer.android.com/guide/topics/resources/complex-xml-resources.html
Change-Id: I8274c85e25cabf90423141c228697e873167d136
diff --git a/tools/aapt2/io/File.h b/tools/aapt2/io/File.h
index b4d4971..807981e 100644
--- a/tools/aapt2/io/File.h
+++ b/tools/aapt2/io/File.h
@@ -19,7 +19,10 @@
#include "Source.h"
#include "io/Data.h"
+#include "util/Util.h"
+#include <android-base/macros.h>
+#include <list>
#include <memory>
#include <vector>
@@ -50,6 +53,37 @@
* a ZIP archive from the path to the containing ZIP archive.
*/
virtual const Source& getSource() const = 0;
+
+ IFile* createFileSegment(size_t offset, size_t len);
+
+private:
+ // Any segments created from this IFile need to be owned by this IFile, so keep them
+ // in a list. This will never be read, so we prefer better insertion performance
+ // than cache locality, hence the list.
+ std::list<std::unique_ptr<IFile>> mSegments;
+};
+
+/**
+ * An IFile that wraps an underlying IFile but limits it to a subsection of that file.
+ */
+class FileSegment : public IFile {
+public:
+ explicit FileSegment(IFile* file, size_t offset, size_t len) :
+ mFile(file), mOffset(offset), mLen(len) {
+ }
+
+ std::unique_ptr<IData> openAsData() override;
+
+ const Source& getSource() const override {
+ return mFile->getSource();
+ }
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(FileSegment);
+
+ IFile* mFile;
+ size_t mOffset;
+ size_t mLen;
};
class IFileCollectionIterator {