bintools/rcomp/src/NAMEIDMA.CPP
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 #include <assert.h>
       
    20 #include <ctype.h>
       
    21 #include <stdlib.h>
       
    22 #include <stdio.h>
       
    23 #include "NAMEIDMA.H"
       
    24 #include "ERRORHAN.H"
       
    25 
       
    26 #if defined(__MSVCDOTNET__) || defined(__TOOLS2__)
       
    27 using std::endl;
       
    28 #endif //__MSVCDOTNET__
       
    29 
       
    30 #if defined(__VC32__)
       
    31 #pragma warning( disable : 4702 )	// unreachable code
       
    32 #endif
       
    33 
       
    34 NameIdMap::NameIdMap()
       
    35 	{}
       
    36 	
       
    37 NameIdMap::~NameIdMap()
       
    38 	{
       
    39 	DeleteAll();
       
    40 	}
       
    41 	
       
    42 void NameIdMap::Add(String aName, unsigned long aId)
       
    43 	{
       
    44 	Array::Add(new NameIdItem(aName,aId));
       
    45 	}
       
    46 	
       
    47 unsigned long NameIdMap::FindId(String aNameSought) const
       
    48 	{
       
    49 	NameIdMapIterator next(*this);
       
    50 	NameIdItem* p;
       
    51 	while((p = next()) != NULL)
       
    52 		if(p->iName == aNameSought)
       
    53 			return p->iId;
       
    54 	ErrorHandler::OutputErrorLine("Link name not found");
       
    55 	exit(1);
       
    56 	// C4702: unreachable code			
       
    57 	}
       
    58 
       
    59 int NameIdMap::IsStored(String aNameSought) const
       
    60 	{
       
    61 	NameIdMapIterator next( * this);
       
    62 	NameIdItem * p;
       
    63 	while((p = next())!=NULL)
       
    64 		if(p->iName == aNameSought)
       
    65 			return 1;
       
    66 	return 0;
       
    67 	}
       
    68 
       
    69 ostream & operator<<(ostream& os,NameIdMap& o)
       
    70 	{
       
    71 	os << "ResourceNameIds ******" << endl;
       
    72 	NameIdMapIterator next(o);
       
    73 	NameIdItem* p;
       
    74 	while((p = next() ) != NULL)
       
    75 		os << *p;
       
    76 	return os;
       
    77 	}
       
    78 
       
    79 //
       
    80 
       
    81 NameIdItem::NameIdItem(String aNameToSet,unsigned long aIdToSet):
       
    82 	iName(aNameToSet),
       
    83 	iId(aIdToSet)
       
    84 	{}
       
    85 
       
    86 ostream & operator<<(ostream& os,NameIdItem& o)
       
    87 	{
       
    88 	os << "NameIdItem " << o.iName << "\t" << o.iId << endl;
       
    89 	return os;
       
    90 	}
       
    91 
       
    92 NameIdMapIterator::NameIdMapIterator(const NameIdMap& aMap):
       
    93 	ArrayIterator(aMap)
       
    94 	{}
       
    95 
       
    96 NameIdItem* NameIdMapIterator::operator()()
       
    97 	{
       
    98 	return (NameIdItem*)ArrayIterator::operator()();
       
    99 	}
       
   100