Main | License | Installation | FAQ | Screenshots | Contact | Links | Sf.net | Freshmeat.net | KDE-Apps.org
Requirements | Design | Modules | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

unitMap.cpp File Reference

#include <klocale.h>
#include <iostream>
#include "unitMap.hpp"

Go to the source code of this file.

Functions

map< string, string > createUnitMap (void)
map< string, string > createInverseUnitMap (void)
QStringList createUnitStringList (void)


Function Documentation

map< string, string > createInverseUnitMap ( void   ) 

Create an inverse unit map. Creates a map, which maps mealmaster's unit-abbreviations on unit-names.

Returns:
Map for mapping unit-abbreviations to unit-names in the current language.
Date:
Sat Feb 05 2005
Author:
Jan Wedekind (wedesoft@users.sourceforge.net)

Definition at line 64 of file unitMap.cpp.

00065 {
00066   map< string, string > unitMap( createUnitMap() );
00067 
00068   map< string, string > retVal;
00069 
00070   for ( map< string, string >::const_iterator i = unitMap.begin();
00071         i != unitMap.end(); i++ )
00072     retVal.insert( make_pair( i->second, i->first ) );
00073   retVal[ "T" ] = (const char *)i18n( "tablespoon" );
00074   retVal[ "t" ] = (const char *)i18n( "teaspoon" );
00075   return retVal;
00076 }

map< string, string > createUnitMap ( void   ) 

Create an unit map. Creates a map, which maps unit-names on the abbreviations, which are used for representation in the mealmaster file-format.

Returns:
Map for mapping unit-names of the current language to mealmaster's abbreviations.
Date:
Sat Feb 05 2005
Author:
Jan Wedekind (wedesoft@users.sourceforge.net)

Definition at line 24 of file unitMap.cpp.

Referenced by createInverseUnitMap(), createUnitStringList(), and mealmasterMapFile().

00025 {
00026   map< string, string > retVal;
00027 
00028   retVal[ ""                    ] = ""  ;
00029   retVal[ i18n( "per serving" ) ] = "x" ;
00030   retVal[ i18n( "small"       ) ] = "sm";
00031   retVal[ i18n( "medium"      ) ] = "md";
00032   retVal[ i18n( "large"       ) ] = "lg";
00033   retVal[ i18n( "can"         ) ] = "cn";
00034   retVal[ i18n( "package"     ) ] = "pk";
00035   retVal[ i18n( "pinch"       ) ] = "pn";
00036   retVal[ i18n( "drop"        ) ] = "dr";
00037   retVal[ i18n( "dash"        ) ] = "ds";
00038   retVal[ i18n( "carton"      ) ] = "ct";
00039   retVal[ i18n( "bunch"       ) ] = "bn";
00040   retVal[ i18n( "slice"       ) ] = "sl";
00041   retVal[ i18n( "each"        ) ] = "ea";
00042   retVal[ i18n( "teaspoon"    ) ] = "ts";
00043   retVal[ i18n( "tablespoon"  ) ] = "tb";
00044   retVal[ i18n( "fluid ounce" ) ] = "fl";
00045   retVal[ i18n( "cup"         ) ] = "c" ;
00046   retVal[ i18n( "pint"        ) ] = "pt";
00047   retVal[ i18n( "quart"       ) ] = "qt";
00048   retVal[ i18n( "gallon"      ) ] = "ga";
00049   retVal[ i18n( "ounce"       ) ] = "oz";
00050   retVal[ i18n( "pound"       ) ] = "lb";
00051   retVal[ i18n( "milliliter"  ) ] = "ml";
00052   retVal[ i18n( "cubic cm"    ) ] = "cb";
00053   retVal[ i18n( "centiliter"  ) ] = "cl";
00054   retVal[ i18n( "deciliter"   ) ] = "dl";
00055   retVal[ i18n( "liter"       ) ] = "l" ;
00056   retVal[ i18n( "milligram"   ) ] = "mg";
00057   retVal[ i18n( "centigram"   ) ] = "cg";
00058   retVal[ i18n( "decigram"    ) ] = "dg";
00059   retVal[ i18n( "gram"        ) ] = "g" ;
00060   retVal[ i18n( "kilogram"    ) ] = "kg";
00061   return retVal;
00062 }

QStringList createUnitStringList ( void   ) 

Method for creating list of unit names. Creates a list for Qt, which contains the allowed units.

Returns:
List of unit names in the current language.
Date:
Sat Feb 05 2005
Author:
Jan Wedekind (wedesoft@users.sourceforge.net)

Definition at line 79 of file unitMap.cpp.

00080 {
00081   // Use code of 'createUnitMap'-method.
00082   map< string, string > unitMap( createUnitMap() );
00083   QStringList retVal;
00084   for ( map< string, string >::const_iterator i = unitMap.begin();
00085         i != unitMap.end(); i++ )
00086     retVal << (*i).first.c_str();
00087 #ifndef NDEBUG
00088   cerr << retVal.size() << " units." << endl;
00089 #endif
00090   return retVal;
00091 }



anymeal 0.30 - recipe management software - Make the most of your food! - © Jan Wedekind Sun Sep 14 16:01:27 2008 - GNU Free Documentation License