bintools/rcomp/inc/RESOURCE.H
changeset 0 044383f39525
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __RESOURCE_H__
       
    20 #define __RESOURCE_H__
       
    21 
       
    22 #include "ASTRING.H" 
       
    23 #include "STRINGAR.H"
       
    24 #include "STRUCTST.H"
       
    25 #include "STACK.H"   
       
    26 #include "RCBINSTR.H"
       
    27 #include "NAMEIDMA.H"
       
    28 
       
    29 
       
    30 enum { EResourceItem, ESimpleResourceItem, EArrayResourceItem, EStructTypeResourceItem, EStructArrayResourceItem };
       
    31 
       
    32 class ResourceItem;
       
    33 
       
    34 // ResourceItemArray
       
    35 
       
    36 class ResourceItemArray : public Array, public StackItem, public ArrayItem
       
    37 	{
       
    38 	friend ostream & operator<< ( ostream & os, ResourceItemArray & o);
       
    39 public:
       
    40 	ResourceItemArray();
       
    41 	~ResourceItemArray();
       
    42 	void Add( ResourceItem * pNewItem);
       
    43 	void FillFromStruct( const String & StructName);
       
    44 	void Set( const String & Label, const String & Value);
       
    45 	void Set( const String & Label, const StringArray & Values);
       
    46 	ResourceItem * Find( const String & LabelSought);
       
    47 	void AddDefault();
       
    48 	void StreamOut(ResourceDataStream& aStream) const;
       
    49 private:
       
    50 	DataType iLenType;
       
    51 	};
       
    52 
       
    53 // ResourceItemArrayIterator
       
    54 
       
    55 class ResourceItemArrayIterator : public ArrayIterator
       
    56 	{
       
    57 public:
       
    58 	ResourceItemArrayIterator( const ResourceItemArray & c);
       
    59 	ResourceItem * operator() ();
       
    60 	};
       
    61 
       
    62 // ResourceItemArrayArray
       
    63 
       
    64 class ResourceItemArrayArray : public Array
       
    65 	{
       
    66 	friend ostream & operator<< ( ostream & os, ResourceItemArrayArray & o);
       
    67 public:
       
    68 	ResourceItemArrayArray();
       
    69 	~ResourceItemArrayArray();
       
    70 	void Add( ResourceItemArray * pNewItem);
       
    71 	void StreamOut(ResourceDataStream& aStream) const;
       
    72 	};
       
    73 
       
    74 // ResourceItemArrayArrayIterator
       
    75 
       
    76 class ResourceItemArrayArrayIterator : public ArrayIterator
       
    77 	{
       
    78 public:
       
    79 	ResourceItemArrayArrayIterator( const ResourceItemArrayArray & c);
       
    80 	ResourceItemArray * operator() ();
       
    81 	};
       
    82 
       
    83 
       
    84 // ResourceHeader
       
    85 
       
    86 class ResourceHeader : public ArrayItem
       
    87 	{
       
    88 	friend ostream & operator<< ( ostream & os, ResourceHeader & o);
       
    89 public:
       
    90 	ResourceHeader( String LabelToSet);
       
    91 	ResourceHeader();
       
    92 	~ResourceHeader();
       
    93 	void AddDefault();
       
    94 	void Write( ostream &os);
       
    95 	void SetResourceId(NameIdMap& aMap, unsigned long aId, int aFormatAsHex);
       
    96 	void StreamOut(RCBinaryStream& aStream, int& aSizeOfLargestResourceWhenUncompressed, const char* aDumpFile);
       
    97 	inline bool ContainsCompressedUnicode() const {return iContainsCompressedUnicode;}
       
    98 public:
       
    99 	String iLabel;
       
   100 	ResourceItemArray iRIA;
       
   101 	unsigned char iLocal;
       
   102 	unsigned long iResourceId;
       
   103 	int iFormatAsHex;
       
   104 	bool iContainsCompressedUnicode;
       
   105 	};
       
   106 
       
   107 // ResourceItem
       
   108 
       
   109 class ResourceItem : public ArrayItem, public StackItem
       
   110 	{
       
   111 public:
       
   112 	virtual ResourceItemArray * GetRIA() = 0;
       
   113 	virtual void Set( const String & ValueToSet) = 0;
       
   114 	virtual void Set( const StringArray & ValuesToSet) = 0;
       
   115 	virtual ostream & StreamOut ( ostream & os) = 0;
       
   116 	virtual void StreamOut(ResourceDataStream& aStream) const = 0;
       
   117 	virtual void AddDefault() = 0;
       
   118 	virtual void SetSRLink( unsigned long SRLinkToSet) = 0;	
       
   119 	void Set(const String* FileNameToSet, int LineNumberToSet);
       
   120 	void RegisterErrorLocation();
       
   121 	int GetResourceItemType();
       
   122 	String GetLabel();
       
   123 protected:
       
   124 	ResourceItem( const String & Label, int aResourceItemType=EResourceItem);
       
   125 	ResourceItem & operator= ( const ResourceItem &);
       
   126 public:
       
   127 	const String& iLabel;
       
   128 	const String* iFileName;
       
   129 	int iLineNumber;
       
   130 private:
       
   131 	int iResourceItemType;
       
   132 	};
       
   133 
       
   134 // SimpleResourceItem
       
   135 
       
   136 class SimpleResourceItem : public ResourceItem
       
   137 	{
       
   138 public:
       
   139 	SimpleResourceItem(SimpleStructItem*);
       
   140 	void Set(const String& aValueToSet);
       
   141 	void Set(const StringArray& aValuesToSet);
       
   142 	virtual ostream& StreamOut(ostream& os);
       
   143 	friend ostream& operator<<(ostream& os,SimpleResourceItem & o);
       
   144 	virtual void StreamOut(ResourceDataStream& aStream) const;
       
   145 	virtual void AddDefault();
       
   146 	virtual void SetSRLink(unsigned long aSRLinkToSet);
       
   147 private:
       
   148 	ResourceItemArray* GetRIA();
       
   149 public:
       
   150 	SimpleStructItem* iStructItem;
       
   151 private:
       
   152 	String iValue;
       
   153 	unsigned long iLinkValue;
       
   154 	unsigned char iValueSet;
       
   155 	};
       
   156 
       
   157 // ArrayResourceItem
       
   158 
       
   159 class ArrayResourceItem : public ResourceItem
       
   160 	{
       
   161 	friend ostream& operator<<(ostream& os,ArrayResourceItem& aItem);
       
   162 public:
       
   163 	ArrayResourceItem(ArrayStructItem *);
       
   164 	~ArrayResourceItem();
       
   165 	void Set(const String& aValueToSet);
       
   166 	void Set(const StringArray& aValuesToSet);
       
   167 	ostream & StreamOut(ostream& os);
       
   168 	virtual void StreamOut(ResourceDataStream& aStream) const;
       
   169 	virtual void AddDefault();
       
   170 	virtual void SetSRLink(unsigned long aSRLinkToSet);
       
   171 private:
       
   172 	ResourceItemArray* GetRIA();
       
   173 public:
       
   174 	ArrayStructItem* iStructItem;
       
   175 private:
       
   176 	StringArray iValues;
       
   177 	};
       
   178 
       
   179 // StructTypeResourceItem
       
   180 
       
   181 class StructTypeResourceItem : public ResourceItem
       
   182 	{
       
   183 public:
       
   184 	StructTypeResourceItem(StructTypeStructItem*);
       
   185 	void Set(const String& ValueToSet);
       
   186 	void Set(const StringArray& ValuesToSet);
       
   187 	ostream& StreamOut(ostream& os);
       
   188 	friend ostream& operator<<(ostream& os,StructTypeResourceItem& o);
       
   189 	virtual void StreamOut(ResourceDataStream& aStream) const;
       
   190 	virtual void AddDefault();
       
   191 	virtual void SetSRLink(unsigned long aSRLinkToSet);
       
   192 	ResourceItemArray* GetRIA();
       
   193 public:
       
   194 	StructTypeStructItem* iStructItem;
       
   195 	ResourceItemArray iResourceItems;
       
   196 	};
       
   197 
       
   198 // StructArrayResourceItem
       
   199 
       
   200 class StructArrayResourceItem : public ResourceItem
       
   201 	{
       
   202 	friend ostream& operator<<(ostream& os,StructArrayResourceItem& aItem);
       
   203 public:
       
   204 	StructArrayResourceItem(StructArrayStructItem*);
       
   205 	void Set(const String& ValueToSet);
       
   206 	void Set(const StringArray& ValuesToSet);
       
   207 	ResourceItemArray* GetRIA();
       
   208 	ostream& StreamOut(ostream& os);
       
   209 	virtual void StreamOut(ResourceDataStream& aStream) const;
       
   210 	virtual void AddDefault();
       
   211 	virtual void SetSRLink(unsigned long SRLinkToSet);
       
   212 public:
       
   213 	StructArrayStructItem* iStructItem;
       
   214 	ResourceItemArrayArray iArrayOfResourceItemArrays;
       
   215 	ResourceItemArray* iLastRIA;
       
   216 	};
       
   217 
       
   218 #endif