aknlayoutcompiler/src/ZoomLevelNames.cpp
changeset 0 f58d6ec98e88
child 1 b700e12870ca
equal deleted inserted replaced
-1:000000000000 0:f58d6ec98e88
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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 // disable "identifier was truncated to '255' characters in the browser information" warning
       
    20 #pragma warning (disable:4786)
       
    21 
       
    22 // disable "decorated name length exceeded, name was truncated" warning	
       
    23 #pragma warning (disable:4503)
       
    24 
       
    25 #include "ZoomLevelNames.h"
       
    26 #include "LayoutCompilerErr.h"
       
    27 #include "CodeGenConsts.h"
       
    28 
       
    29 #include <cdlcompilertoolkit/cdltkutil.h>
       
    30 
       
    31 #include <akndef.hrh>
       
    32 
       
    33 #include <fstream>
       
    34 #include <iostream>
       
    35 
       
    36 using namespace CdlCompilerToolkit;
       
    37 
       
    38 typedef LayoutProcessArgsErr<CZoomLevelNames> ZoomLevelNamesArgsErr;
       
    39 
       
    40 //
       
    41 // CZoomLevelNames
       
    42 //
       
    43 
       
    44 void CZoomLevelNames::ProcessOptions(vector<string>& aArgs)
       
    45 	{
       
    46 	bool zoomFileOk = false;
       
    47 	ifstream in;
       
    48 	string zoomFile;
       
    49 
       
    50 	for(vector<string>::iterator pArg = aArgs.begin(); pArg != aArgs.end(); ++pArg)
       
    51 		{
       
    52 		string& arg = *pArg;
       
    53 		if (arg.size() >= 2 && arg.substr(0,2) == "-z")
       
    54 			{
       
    55 			zoomFile = arg.substr(2);
       
    56 			try
       
    57 				{
       
    58 				CdlTkUtil::OpenInput(in, zoomFile);
       
    59 				zoomFileOk = true;
       
    60 				}
       
    61 			catch (const CdlTkFileOpenErr&)
       
    62 				{
       
    63 				}
       
    64 			aArgs.erase(pArg);
       
    65 			break;
       
    66 			}
       
    67 		}
       
    68 	if(zoomFileOk)
       
    69 		{
       
    70 		string line;
       
    71 		while (!in.eof())
       
    72 			{
       
    73 			getline(in, line);
       
    74 			int comma = line.find(",");
       
    75 			if(comma == string::npos)
       
    76 				{
       
    77 				cerr << "Zoom file incorrect format." << endl;
       
    78 				throw GeneralErr("Zoom file incorrect format");
       
    79 				}
       
    80 			int num = CdlTkUtil::ParseInt(line.substr(0, comma));
       
    81 			insert(make_pair(num, line.substr(comma+1)));
       
    82 			}
       
    83 		in.close();
       
    84 		}
       
    85 	else
       
    86 		{
       
    87 		// assume that normal zoom is the only one
       
    88 		insert(make_pair(EAknUiZoomNormal, KDefaultZoomInstanceName));
       
    89 		}
       
    90 	}