aknlayoutcompiler/inc/CppWriter.h
changeset 0 f58d6ec98e88
equal deleted inserted replaced
-1:000000000000 0:f58d6ec98e88
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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 "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 CPPWRITER_H
       
    20 #define CPPWRITER_H
       
    21 
       
    22 // disable "identifier was truncated to '255' characters in the browser information" warning
       
    23 #pragma warning (disable:4786)
       
    24 #include <vector>
       
    25 #include <string>
       
    26 #include <iosfwd>
       
    27 #include "WriterBase.h"
       
    28 using namespace std;
       
    29 
       
    30 
       
    31 
       
    32 
       
    33 /**
       
    34 *  TValuesCppWriter
       
    35 *  Write out layout cell values for AknLayout.dll
       
    36 */
       
    37 class TValuesCppWriter
       
    38 	{
       
    39 public:
       
    40 	TValuesCppWriter(TValues& aValues) : iValues(aValues) {}
       
    41 	void WriteCpp(ostream& aCpp);
       
    42 
       
    43 private:
       
    44 	TValues& iValues;
       
    45 	};
       
    46 
       
    47 
       
    48 /**
       
    49 *  TLayoutLineCppWriter
       
    50 *  Base class for writing out a layout line for AknLayout.dll
       
    51 */
       
    52 class TLayoutLineCppWriter
       
    53 	{
       
    54 public:
       
    55 	TLayoutLineCppWriter(TLayoutLine& aLine) : iLine(aLine) {}
       
    56 	void WriteCpp(ostream& aCpp); 
       
    57 	virtual string Name()=0;
       
    58 	virtual void WriteMacro(ostream& aLag) = 0;
       
    59 	virtual void FillParamLists(vector<string>& aDef, vector<string>& aCtor) = 0;
       
    60 
       
    61 	void WriteCppData(ostream& aCpp);
       
    62 	int WriteParamList(ostream& aLag, const vector<string>& aParams);
       
    63 
       
    64 protected:
       
    65 	virtual void WriteLineClassName(ostream& aCpp) = 0;
       
    66 	virtual void WriteVarCppData(ostream& aCpp) = 0;
       
    67 	virtual void WriteFixedCppData(ostream& aCpp) = 0;
       
    68 
       
    69 	int ValCount();
       
    70 
       
    71 protected:
       
    72 	TLayoutLine& iLine;
       
    73 	};
       
    74 
       
    75 /**
       
    76 *  TWindowLineCppWriter 
       
    77 *  Write out a window line for AknLayout.dll
       
    78 */
       
    79 class TWindowLineCppWriter : public TLayoutLineCppWriter
       
    80 	{
       
    81 public:
       
    82 	TWindowLineCppWriter(TLayoutLine& aLine) : TLayoutLineCppWriter(aLine) {}
       
    83 	void WriteMacro(ostream& aLag);
       
    84 	string Name();
       
    85 	void FillParamLists(vector<string>& aDef, vector<string>& aCtor);
       
    86 
       
    87 private:
       
    88 	void WriteVarCppData(ostream& aCpp);
       
    89 	void WriteFixedCppData(ostream& aCpp);
       
    90 	void WriteLineClassName(ostream& aCpp);
       
    91 	};
       
    92 
       
    93 /**
       
    94 *  TTextLineCppWriter 
       
    95 *  Write out a text line for AknLayout.dll
       
    96 */
       
    97 class TTextLineCppWriter : public TLayoutLineCppWriter
       
    98 	{
       
    99 public:
       
   100 	TTextLineCppWriter(TLayoutLine& aLine) : TLayoutLineCppWriter(aLine) {}
       
   101 	void WriteMacro(ostream& aLag);
       
   102 	string Name();
       
   103 	void FillParamLists(vector<string>& aDef, vector<string>& aCtor);
       
   104 
       
   105 private:
       
   106 	void WriteVarCppData(ostream& aCpp);
       
   107 	void WriteFixedCppData(ostream& aCpp);
       
   108 	void WriteLineClassName(ostream& aCpp);
       
   109 
       
   110 	// Specific to text
       
   111 	void WriteMultiLineTextParamList(ostream& aLag, const vector<string>& aParams);
       
   112 
       
   113 private:
       
   114 	bool iBaseLineVariation;
       
   115 	};
       
   116 
       
   117 
       
   118 /**
       
   119 *  TLayoutTableCppWriter
       
   120 *  Write out a layout table for AknLayout.dll
       
   121 */
       
   122 class TLayoutTableCppWriter
       
   123 	{
       
   124 public:
       
   125 	TLayoutTableCppWriter(TLayoutTable& aTable) : iTable(aTable) {}
       
   126 	void WriteCppLineData(ostream& aCpp);
       
   127 	void WriteCppTableData(ostream& aCpp);
       
   128 	void WriteLag(ostream& aLag);
       
   129 	void WriteLagSubTable(const TLayoutTable::TLayoutSubTable& aSubTable, int aCount, ostream& aLag);
       
   130 	static TLayoutLineCppWriter* CreateLayoutLineCppWriter(TLayoutLine& aData, TLayoutTable& iTable);
       
   131 
       
   132 private:
       
   133 	TLayoutTable& iTable;
       
   134 	};
       
   135 
       
   136 
       
   137 /**
       
   138 *  TLayoutCppWriter
       
   139 *  Write out a layout for AknLayout.dll
       
   140 */
       
   141 class TLayoutCppWriter
       
   142 	{
       
   143 public:
       
   144 	TLayoutCppWriter(TLayout& aLayout) : iLayout(aLayout) {}
       
   145 	void WriteCppLineData(ostream& aCpp);
       
   146 	void WriteCppTableData(ostream& aCpp);
       
   147 	void WriteLag(ostream& aLag);
       
   148 
       
   149 private:
       
   150 	TLayout& iLayout;
       
   151 	};
       
   152 
       
   153 
       
   154 /**
       
   155 *  TLayoutLineTable 
       
   156 *  Represents and writes a table of layout lines for AknLayout.dll
       
   157 */
       
   158 class TLayoutLineTable : public vector<TLayoutLine*>
       
   159 	{
       
   160 public:
       
   161 	void WriteCpp(ostream& aCpp);
       
   162 	void WriteLag(ostream& aLag);
       
   163 	};
       
   164 
       
   165 
       
   166 /**
       
   167 *  TCppWriter 
       
   168 *  Write the source code for AknLayout.dll
       
   169 */
       
   170 class TCppWriter : public TLayWriterBase
       
   171 	{
       
   172 public:
       
   173 	TCppWriter(TLayout& aLayout, const std::string& aName);
       
   174 	void Write(const std::string& aLayName);
       
   175 
       
   176 private:
       
   177 	void Output(const string& aCpp, const string& aLag, const string& aLayName);
       
   178 
       
   179 	void WriteCppHeader(ostream& aCpp);
       
   180 	void WriteCppFooter(ostream& aCpp, const string& aLayName);
       
   181 	void WriteLagHeader(ostream& aLag);
       
   182 
       
   183 	void BuildLayoutLineTable();
       
   184 
       
   185 private:
       
   186 	TLayoutLineTable iLineTable;
       
   187 	string iShortName;
       
   188 	};
       
   189 
       
   190 #endif
       
   191 
       
   192 // End of File