]> git.saurik.com Git - android/aapt.git/blame_incremental - Bundle.h
Implement compatibility support for WRITE_SDCARD permission.
[android/aapt.git] / Bundle.h
... / ...
CommitLineData
1//
2// Copyright 2006 The Android Open Source Project
3//
4// State bundle. Used to pass around stuff like command-line args.
5//
6#ifndef __BUNDLE_H
7#define __BUNDLE_H
8
9#include <stdlib.h>
10#include <utils.h> // android
11#include <utils/String8.h>
12#include <utils/Vector.h>
13
14/*
15 * Things we can do.
16 */
17typedef enum Command {
18 kCommandUnknown = 0,
19 kCommandVersion,
20 kCommandList,
21 kCommandDump,
22 kCommandAdd,
23 kCommandRemove,
24 kCommandPackage,
25} Command;
26
27/*
28 * Bundle of goodies, including everything specified on the command line.
29 */
30class Bundle {
31public:
32 Bundle(void)
33 : mCmd(kCommandUnknown), mVerbose(false), mAndroidList(false),
34 mForce(false), mGrayscaleTolerance(0), mMakePackageDirs(false),
35 mUpdate(false), mExtending(false),
36 mRequireLocalization(false), mPseudolocalize(false),
37 mCompressionMethod(0), mOutputAPKFile(NULL),
38 mAssetSourceDir(NULL),
39 mAndroidManifestFile(NULL), mPublicOutputFile(NULL),
40 mRClassDir(NULL), mResourceIntermediatesDir(NULL),
41 mArgc(0), mArgv(NULL)
42 {}
43 ~Bundle(void) {}
44
45 /*
46 * Set the command value. Returns "false" if it was previously set.
47 */
48 Command getCommand(void) const { return mCmd; }
49 void setCommand(Command cmd) { mCmd = cmd; }
50
51 /*
52 * Command modifiers. Not all modifiers are appropriate for all
53 * commands.
54 */
55 bool getVerbose(void) const { return mVerbose; }
56 void setVerbose(bool val) { mVerbose = val; }
57 bool getAndroidList(void) const { return mAndroidList; }
58 void setAndroidList(bool val) { mAndroidList = val; }
59 bool getForce(void) const { return mForce; }
60 void setForce(bool val) { mForce = val; }
61 void setGrayscaleTolerance(int val) { mGrayscaleTolerance = val; }
62 int getGrayscaleTolerance() { return mGrayscaleTolerance; }
63 bool getMakePackageDirs(void) const { return mMakePackageDirs; }
64 void setMakePackageDirs(bool val) { mMakePackageDirs = val; }
65 bool getUpdate(void) const { return mUpdate; }
66 void setUpdate(bool val) { mUpdate = val; }
67 bool getExtending(void) const { return mExtending; }
68 void setExtending(bool val) { mExtending = val; }
69 bool getRequireLocalization(void) const { return mRequireLocalization; }
70 void setRequireLocalization(bool val) { mRequireLocalization = val; }
71 bool getPseudolocalize(void) const { return mPseudolocalize; }
72 void setPseudolocalize(bool val) { mPseudolocalize = val; }
73 int getCompressionMethod(void) const { return mCompressionMethod; }
74 void setCompressionMethod(int val) { mCompressionMethod = val; }
75 const char* getOutputAPKFile() const { return mOutputAPKFile; }
76 void setOutputAPKFile(const char* val) { mOutputAPKFile = val; }
77
78 /*
79 * Input options.
80 */
81 const char* getAssetSourceDir() const { return mAssetSourceDir; }
82 void setAssetSourceDir(const char* dir) { mAssetSourceDir = dir; }
83 const android::Vector<const char*>& getResourceSourceDirs() const { return mResourceSourceDirs; }
84 void addResourceSourceDir(const char* dir) { mResourceSourceDirs.insertAt(dir,0); }
85 const char* getAndroidManifestFile() const { return mAndroidManifestFile; }
86 void setAndroidManifestFile(const char* file) { mAndroidManifestFile = file; }
87 const char* getPublicOutputFile() const { return mPublicOutputFile; }
88 void setPublicOutputFile(const char* file) { mPublicOutputFile = file; }
89 const char* getRClassDir() const { return mRClassDir; }
90 void setRClassDir(const char* dir) { mRClassDir = dir; }
91 const char* getConfigurations() const { return mConfigurations.size() > 0 ? mConfigurations.string() : NULL; }
92 void addConfigurations(const char* val) { if (mConfigurations.size() > 0) { mConfigurations.append(","); mConfigurations.append(val); } else { mConfigurations = val; } }
93 const char* getResourceIntermediatesDir() const { return mResourceIntermediatesDir; }
94 void setResourceIntermediatesDir(const char* dir) { mResourceIntermediatesDir = dir; }
95 const android::Vector<const char*>& getPackageIncludes() const { return mPackageIncludes; }
96 void addPackageInclude(const char* file) { mPackageIncludes.add(file); }
97 const android::Vector<const char*>& getJarFiles() const { return mJarFiles; }
98 void addJarFile(const char* file) { mJarFiles.add(file); }
99 const android::Vector<const char*>& getNoCompressExtensions() const { return mNoCompressExtensions; }
100 void addNoCompressExtension(const char* ext) { mNoCompressExtensions.add(ext); }
101
102 const char* getMinSdkVersion() const { return mMinSdkVersion; }
103 void setMinSdkVersion(const char* val) { mMinSdkVersion = val; }
104 const char* getTargetSdkVersion() const { return mTargetSdkVersion; }
105 void setTargetSdkVersion(const char* val) { mTargetSdkVersion = val; }
106 const char* getMaxSdkVersion() const { return mMaxSdkVersion; }
107 void setMaxSdkVersion(const char* val) { mMaxSdkVersion = val; }
108 const char* getVersionCode() const { return mVersionCode; }
109 void setVersionCode(const char* val) { mVersionCode = val; }
110 const char* getVersionName() const { return mVersionName; }
111 void setVersionName(const char* val) { mVersionName = val; }
112
113 /*
114 * Set and get the file specification.
115 *
116 * Note this does NOT make a copy of argv.
117 */
118 void setFileSpec(char* const argv[], int argc) {
119 mArgc = argc;
120 mArgv = argv;
121 }
122 int getFileSpecCount(void) const { return mArgc; }
123 const char* getFileSpecEntry(int idx) const { return mArgv[idx]; }
124 void eatArgs(int n) {
125 if (n > mArgc) n = mArgc;
126 mArgv += n;
127 mArgc -= n;
128 }
129
130#if 0
131 /*
132 * Package count. Nothing to do with anything else here; this is
133 * just a convenient place to stuff it so we don't have to pass it
134 * around everywhere.
135 */
136 int getPackageCount(void) const { return mPackageCount; }
137 void setPackageCount(int val) { mPackageCount = val; }
138#endif
139
140private:
141 /* commands & modifiers */
142 Command mCmd;
143 bool mVerbose;
144 bool mAndroidList;
145 bool mForce;
146 int mGrayscaleTolerance;
147 bool mMakePackageDirs;
148 bool mUpdate;
149 bool mExtending;
150 bool mRequireLocalization;
151 bool mPseudolocalize;
152 int mCompressionMethod;
153 const char* mOutputAPKFile;
154 const char* mAssetSourceDir;
155 const char* mAndroidManifestFile;
156 const char* mPublicOutputFile;
157 const char* mRClassDir;
158 const char* mResourceIntermediatesDir;
159 android::String8 mConfigurations;
160 android::Vector<const char*> mPackageIncludes;
161 android::Vector<const char*> mJarFiles;
162 android::Vector<const char*> mNoCompressExtensions;
163 android::Vector<const char*> mResourceSourceDirs;
164
165 const char* mMinSdkVersion;
166 const char* mTargetSdkVersion;
167 const char* mMaxSdkVersion;
168 const char* mVersionCode;
169 const char* mVersionName;
170
171 /* file specification */
172 int mArgc;
173 char* const* mArgv;
174
175#if 0
176 /* misc stuff */
177 int mPackageCount;
178#endif
179};
180
181#endif // __BUNDLE_H