Home | History | Annotate | Download | only in idmap2
      1 /*
      2  * Copyright (C) 2018 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef IDMAP2_INCLUDE_IDMAP2_RAWPRINTVISITOR_H_
     18 #define IDMAP2_INCLUDE_IDMAP2_RAWPRINTVISITOR_H_
     19 
     20 #include <iostream>
     21 #include <memory>
     22 #include <string>
     23 
     24 #include "androidfw/AssetManager2.h"
     25 #include "idmap2/Idmap.h"
     26 
     27 namespace android {
     28 
     29 class ApkAssets;
     30 
     31 namespace idmap2 {
     32 
     33 class RawPrintVisitor : public Visitor {
     34  public:
     35   explicit RawPrintVisitor(std::ostream& stream) : stream_(stream), offset_(0) {
     36   }
     37   virtual void visit(const Idmap& idmap);
     38   virtual void visit(const IdmapHeader& header);
     39   virtual void visit(const IdmapData& data);
     40   virtual void visit(const IdmapData::Header& header);
     41   virtual void visit(const IdmapData::TypeEntry& type_entry);
     42 
     43  private:
     44   void print(uint16_t value, const char* fmt, ...);
     45   void print(uint32_t value, const char* fmt, ...);
     46   void print(const std::string& value, const char* fmt, ...);
     47 
     48   std::ostream& stream_;
     49   std::unique_ptr<const ApkAssets> target_apk_;
     50   AssetManager2 target_am_;
     51   size_t offset_;
     52   PackageId last_seen_package_id_;
     53 };
     54 
     55 }  // namespace idmap2
     56 }  // namespace android
     57 
     58 #endif  // IDMAP2_INCLUDE_IDMAP2_RAWPRINTVISITOR_H_
     59