~valavanisalex/ubuntu/oneiric/inkscape/inkscape_0.48.1-2ubuntu4

« back to all changes in this revision

Viewing changes to src/util/enums.h

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook, Kees Cook, Ted Gould
  • Date: 2008-02-10 14:20:16 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080210142016-vcnb2zqyhszu0xvb
Tags: 0.46~pre1-0ubuntu1
[ Kees Cook ]
* debian/control:
  - add libgtkspell-dev build-dep to gain GtkSpell features (LP: #183547).
  - update Standards version (no changes needed).
  - add Vcs and Homepage fields.
  - switch to new python-lxml dep.
* debian/{control,rules}: switch from dpatch to quilt for more sanity.
* debian/patches/20_fix_glib_and_gxx43_ftbfs.patch:
  - merged against upstream fixes.
  - added additional fixes for newly written code.
* debian/rules: enable parallel building.

[ Ted Gould ]
* Updating POTFILES.in to make it so things build correctly.
* debian/control:
  - add ImageMagick++ and libboost-dev to build-deps

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * \brief Simplified management of enumerations of svg items with UI labels
 
3
 *
 
4
 * Authors:
 
5
 *   Nicholas Bishop <nicholasbishop@gmail.com>
 
6
 *   Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
 
7
 *
 
8
 * Copyright (C) 2007 Authors
 
9
 *
 
10
 * Released under GNU GPL.  Read the file 'COPYING' for more information.
 
11
 */
 
12
 
 
13
/* IMPORTANT
 
14
 *  When initializing the EnumData struct, you cannot use _(...) to translate strings.
 
15
  * Instead, one must use N_(...) and do the translation every time the string is retreived.
 
16
 */
 
17
 
 
18
 
 
19
#ifndef INKSCAPE_UTIL_ENUMS_H
 
20
#define INKSCAPE_UTIL_ENUMS_H
 
21
 
 
22
#include <glibmm/ustring.h>
 
23
 
 
24
namespace Inkscape {
 
25
namespace Util {
 
26
 
 
27
template<typename E> class EnumData
 
28
{
 
29
public:
 
30
    E id;
 
31
    const Glib::ustring label;
 
32
    const Glib::ustring key;
 
33
};
 
34
 
 
35
template<typename E> class EnumDataConverter
 
36
{
 
37
public:
 
38
    typedef EnumData<E> Data;
 
39
 
 
40
    EnumDataConverter(const EnumData<E>* cd, const int endval)
 
41
        : end(endval), _data(cd)
 
42
    {}
 
43
 
 
44
    E get_id_from_label(const Glib::ustring& label) const
 
45
    {
 
46
        for(int i = 0; i < end; ++i) {
 
47
            if(_data[i].label == label)
 
48
                return (E)i;
 
49
        }
 
50
 
 
51
        return (E)0;
 
52
    }
 
53
 
 
54
    E get_id_from_key(const Glib::ustring& key) const
 
55
    {
 
56
        for(int i = 0; i < end; ++i) {
 
57
            if(_data[i].key == key)
 
58
                return (E)i;
 
59
        }
 
60
 
 
61
        return (E)0;
 
62
    }
 
63
 
 
64
    bool is_valid_key(const Glib::ustring& key) const
 
65
    {
 
66
        for(int i = 0; i < end; ++i) {
 
67
            if(_data[i].key == key)
 
68
                return true;
 
69
        }
 
70
 
 
71
        return false;
 
72
    }
 
73
 
 
74
    const Glib::ustring& get_label(const E e) const
 
75
    {
 
76
        return _data[e].label;
 
77
    }
 
78
 
 
79
    const Glib::ustring& get_key(const E e) const
 
80
    {
 
81
        return _data[e].key;
 
82
    }
 
83
 
 
84
    const EnumData<E>& data(const int i) const
 
85
    {
 
86
        return _data[i];
 
87
    }
 
88
 
 
89
    const int end;
 
90
private:
 
91
    const EnumData<E>* _data;
 
92
};
 
93
 
 
94
 
 
95
}
 
96
}
 
97
 
 
98
#endif
 
99
 
 
100
/*
 
101
  Local Variables:
 
102
  mode:c++
 
103
  c-file-style:"stroustrup"
 
104
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
105
  indent-tabs-mode:nil
 
106
  fill-column:99
 
107
  End:
 
108
*/
 
109
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :