Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

mmap.h File Reference

More...

#include <iostream>
#include "magic/mobject.h"
#include "magic/mmagisupp.h"
#include "magic/mpararr.h"

Go to the source code of this file.

Compounds

class  GenHash
 Generic hash table storage, used by Map. More...

class  GenHashIter
 GenHash iterator. More...

class  HashBucket
 A hash bucket in GenHash and thus in Map; (internal). More...

class  HashFunc
 An interface for hash functions in Genhash (and thus in Map). More...

class  Map
 Associative map, based on GenHash. More...

class  MapIter
 Map iterator. More...

class  MapPair
 A key-value pair in GenHash and thus in Map; (internal). More...


Defines

#define getOrDefault(map, key, def)   (map.getp(key)? *map.getp(key):def)
#define forMap(keytype, valuetype, mapname, varname)   for (MapIter<keytype,valuetype> varname (mapname); !varname.exhausted(); varname.next())
#define forStringMap(mapname, varname)   for (MapIter<String,String> varname (mapname); !varname.exhausted(); varname.next())

Functions

 BEGIN_NAMESPACE (MagiC)
String toString (const StringMap &map)
void splitpairs (StringMap &trg, const String &source, char psep='=', char rsep='&')
String joinpairs (const StringMap &src, char psep='=', char rsep='&')


Detailed Description

Definition in file mmap.h.


Define Documentation

#define forMap keytype,
valuetype,
mapname,
varname       for (MapIter<keytype,valuetype> varname (mapname); !varname.exhausted(); varname.next())
 

Easier iteration for Map.

For example:

forMap (String, String, myMap, iter) { printf("s", (CONSTR) iter.value()); }

, which prints the values in the Map<String,String> to stdout.

Definition at line 517 of file mmap.h.

#define forStringMap mapname,
varname       for (MapIter<String,String> varname (mapname); !varname.exhausted(); varname.next())
 

Easier iteration for Map<String,String> alias StringMap.

For example:

forStringMap (myMap, iter) { printf("s", (CONSTR) iter.value()); }

, which prints the values in the StringMap to stdout.

Definition at line 570 of file mmap.h.

Referenced by toString().

#define getOrDefault map,
key,
def       (map.getp(key)? *map.getp(key):def)
 

Tests if the key is in the map.

If it is, fetches the value, otherwise uses the default.

Usage: getOrDefault(myMap, "a_key", 0.1)

Definition at line 443 of file mmap.h.


Function Documentation

BEGIN_NAMESPACE MagiC   
 

This file is part of the MagiC++ library.

* * Copyright (C) 1998-2002 Marko Grönroos <magi@iki.fi> * *

* This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; see the file COPYING.LIB. If * not, write to the Free Software Foundation, Inc., 59 Temple Place *

  • Suite 330, Boston, MA 02111-1307, USA. * *

String joinpairs const StringMap &    src,
char    psep = '=',
char    rsep = '&'
 

Constructs a string from the map, representing the key-value-pairs in format: "key1=value1&key2=value2&key3=value3".

Reverse for splitPairs().

void splitpairs StringMap &    trg,
const String   source,
char    psep = '=',
char    rsep = '&'
 

Constructs the map from string containing key-value-pairs in format: "key1=value1&key2=value2&key3=value3".

Reverse for joinPairs().

String toString const StringMap &    map
 

Creates a String representation of the Map in format: {"xxx"="yyy", "zzzz"="aaaa"}.

Definition at line 377 of file mmap.cc.

References forStringMap.


Generated on Thu Feb 10 20:06:42 2005 for LibMagiC by doxygen1.2.18