]> git.saurik.com Git - android/aapt.git/blame - Bundle.h
Merge snapshot variant of donut back into the main tree
[android/aapt.git] / Bundle.h
CommitLineData
a534180c
TAOSP
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),
7751daa4 37 mValues(false),
a534180c
TAOSP
38 mCompressionMethod(0), mOutputAPKFile(NULL),
39 mAssetSourceDir(NULL),
40 mAndroidManifestFile(NULL), mPublicOutputFile(NULL),
41 mRClassDir(NULL), mResourceIntermediatesDir(NULL),
53288885
DH
42 mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL),
43 mVersionCode(NULL), mVersionName(NULL),
a534180c
TAOSP
44 mArgc(0), mArgv(NULL)
45 {}
46 ~Bundle(void) {}
47
48 /*
49 * Set the command value. Returns "false" if it was previously set.
50 */
51 Command getCommand(void) const { return mCmd; }
52 void setCommand(Command cmd) { mCmd = cmd; }
53
54 /*
55 * Command modifiers. Not all modifiers are appropriate for all
56 * commands.
57 */
58 bool getVerbose(void) const { return mVerbose; }
59 void setVerbose(bool val) { mVerbose = val; }
60 bool getAndroidList(void) const { return mAndroidList; }
61 void setAndroidList(bool val) { mAndroidList = val; }
62 bool getForce(void) const { return mForce; }
63 void setForce(bool val) { mForce = val; }
64 void setGrayscaleTolerance(int val) { mGrayscaleTolerance = val; }
65 int getGrayscaleTolerance() { return mGrayscaleTolerance; }
66 bool getMakePackageDirs(void) const { return mMakePackageDirs; }
67 void setMakePackageDirs(bool val) { mMakePackageDirs = val; }
68 bool getUpdate(void) const { return mUpdate; }
69 void setUpdate(bool val) { mUpdate = val; }
70 bool getExtending(void) const { return mExtending; }
71 void setExtending(bool val) { mExtending = val; }
72 bool getRequireLocalization(void) const { return mRequireLocalization; }
73 void setRequireLocalization(bool val) { mRequireLocalization = val; }
74 bool getPseudolocalize(void) const { return mPseudolocalize; }
75 void setPseudolocalize(bool val) { mPseudolocalize = val; }
7751daa4
DH
76 bool getValues(void) const { return mValues; }
77 void setValues(bool val) { mValues = val; }
a534180c
TAOSP
78 int getCompressionMethod(void) const { return mCompressionMethod; }
79 void setCompressionMethod(int val) { mCompressionMethod = val; }
80 const char* getOutputAPKFile() const { return mOutputAPKFile; }
81 void setOutputAPKFile(const char* val) { mOutputAPKFile = val; }
82
83 /*
84 * Input options.
85 */
86 const char* getAssetSourceDir() const { return mAssetSourceDir; }
87 void setAssetSourceDir(const char* dir) { mAssetSourceDir = dir; }
88 const android::Vector<const char*>& getResourceSourceDirs() const { return mResourceSourceDirs; }
89 void addResourceSourceDir(const char* dir) { mResourceSourceDirs.insertAt(dir,0); }
90 const char* getAndroidManifestFile() const { return mAndroidManifestFile; }
91 void setAndroidManifestFile(const char* file) { mAndroidManifestFile = file; }
92 const char* getPublicOutputFile() const { return mPublicOutputFile; }
93 void setPublicOutputFile(const char* file) { mPublicOutputFile = file; }
94 const char* getRClassDir() const { return mRClassDir; }
95 void setRClassDir(const char* dir) { mRClassDir = dir; }
96 const char* getConfigurations() const { return mConfigurations.size() > 0 ? mConfigurations.string() : NULL; }
97 void addConfigurations(const char* val) { if (mConfigurations.size() > 0) { mConfigurations.append(","); mConfigurations.append(val); } else { mConfigurations = val; } }
98 const char* getResourceIntermediatesDir() const { return mResourceIntermediatesDir; }
99 void setResourceIntermediatesDir(const char* dir) { mResourceIntermediatesDir = dir; }
100 const android::Vector<const char*>& getPackageIncludes() const { return mPackageIncludes; }
101 void addPackageInclude(const char* file) { mPackageIncludes.add(file); }
102 const android::Vector<const char*>& getJarFiles() const { return mJarFiles; }
103 void addJarFile(const char* file) { mJarFiles.add(file); }
104 const android::Vector<const char*>& getNoCompressExtensions() const { return mNoCompressExtensions; }
105 void addNoCompressExtension(const char* ext) { mNoCompressExtensions.add(ext); }
106
7e486e33
DH
107 const char* getMinSdkVersion() const { return mMinSdkVersion; }
108 void setMinSdkVersion(const char* val) { mMinSdkVersion = val; }
109 const char* getTargetSdkVersion() const { return mTargetSdkVersion; }
110 void setTargetSdkVersion(const char* val) { mTargetSdkVersion = val; }
111 const char* getMaxSdkVersion() const { return mMaxSdkVersion; }
112 void setMaxSdkVersion(const char* val) { mMaxSdkVersion = val; }
113 const char* getVersionCode() const { return mVersionCode; }
114 void setVersionCode(const char* val) { mVersionCode = val; }
115 const char* getVersionName() const { return mVersionName; }
116 void setVersionName(const char* val) { mVersionName = val; }
117
a534180c
TAOSP
118 /*
119 * Set and get the file specification.
120 *
121 * Note this does NOT make a copy of argv.
122 */
123 void setFileSpec(char* const argv[], int argc) {
124 mArgc = argc;
125 mArgv = argv;
126 }
127 int getFileSpecCount(void) const { return mArgc; }
128 const char* getFileSpecEntry(int idx) const { return mArgv[idx]; }
129 void eatArgs(int n) {
130 if (n > mArgc) n = mArgc;
131 mArgv += n;
132 mArgc -= n;
133 }
134
135#if 0
136 /*
137 * Package count. Nothing to do with anything else here; this is
138 * just a convenient place to stuff it so we don't have to pass it
139 * around everywhere.
140 */
141 int getPackageCount(void) const { return mPackageCount; }
142 void setPackageCount(int val) { mPackageCount = val; }
143#endif
144
145private:
146 /* commands & modifiers */
147 Command mCmd;
148 bool mVerbose;
149 bool mAndroidList;
150 bool mForce;
151 int mGrayscaleTolerance;
152 bool mMakePackageDirs;
153 bool mUpdate;
154 bool mExtending;
155 bool mRequireLocalization;
156 bool mPseudolocalize;
7751daa4 157 bool mValues;
a534180c
TAOSP
158 int mCompressionMethod;
159 const char* mOutputAPKFile;
160 const char* mAssetSourceDir;
161 const char* mAndroidManifestFile;
162 const char* mPublicOutputFile;
163 const char* mRClassDir;
164 const char* mResourceIntermediatesDir;
165 android::String8 mConfigurations;
166 android::Vector<const char*> mPackageIncludes;
167 android::Vector<const char*> mJarFiles;
168 android::Vector<const char*> mNoCompressExtensions;
169 android::Vector<const char*> mResourceSourceDirs;
170
7e486e33
DH
171 const char* mMinSdkVersion;
172 const char* mTargetSdkVersion;
173 const char* mMaxSdkVersion;
174 const char* mVersionCode;
175 const char* mVersionName;
176
a534180c
TAOSP
177 /* file specification */
178 int mArgc;
179 char* const* mArgv;
180
181#if 0
182 /* misc stuff */
183 int mPackageCount;
184#endif
185};
186
187#endif // __BUNDLE_H