~ubuntu-branches/ubuntu/vivid/ardour/vivid-proposed

« back to all changes in this revision

Viewing changes to libs/glibmm2/glibmm/quark.h

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler, Jaromír Mikeš, Felipe Sateler
  • Date: 2014-05-22 14:39:25 UTC
  • mfrom: (29 sid)
  • mto: This revision was merged to the branch mainline in revision 30.
  • Revision ID: package-import@ubuntu.com-20140522143925-vwqfo9287pmkrroe
Tags: 1:2.8.16+git20131003-3
* Team upload

[ Jaromír Mikeš ]
* Add -dbg package

[ Felipe Sateler ]
* Upload to experimental

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- c++ -*-
 
2
#ifndef _GLIBMM_QUARK_H
 
3
#define _GLIBMM_QUARK_H
 
4
/* $Id$ */
 
5
 
 
6
/* quark.h
 
7
 *
 
8
 * Copyright 2002 The gtkmm Development Team
 
9
 *
 
10
 * This library is free software; you can redistribute it and/or
 
11
 * modify it under the terms of the GNU Library General Public
 
12
 * License as published by the Free Software Foundation; either
 
13
 * version 2 of the License, or (at your option) any later version.
 
14
 *
 
15
 * This library is distributed in the hope that it will be useful,
 
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
18
 * Library General Public License for more details.
 
19
 *
 
20
 * You should have received a copy of the GNU Library General Public
 
21
 * License along with this library; if not, write to the Free
 
22
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
23
 */
 
24
 
 
25
#include <glib/gquark.h>
 
26
#include <glibmm/ustring.h>
 
27
 
 
28
 
 
29
namespace Glib
 
30
{
 
31
 
 
32
/** Quarks are unique IDs in Glib for strings for use in 
 
33
 * hash table lookups.  Each Quark is unique but may change
 
34
 * between runs.
 
35
 *
 
36
 * QueryQuark is a converter class for looking up but not 
 
37
 * allocating an ID.  An id means the quark lookup failed.
 
38
 *
 
39
 * Quark is used for actions for which the id should live on
 
40
 * While QueryQuark should be used for queries.
 
41
 * ie.
 
42
 *   void set_data (const Quark&, void * data);
 
43
 *   void* get_data (const QueryQuark&);
 
44
 */
 
45
class QueryQuark
 
46
{
 
47
  public:
 
48
    QueryQuark(const GQuark& q);
 
49
    QueryQuark(const ustring& s);
 
50
    QueryQuark(const char*s);
 
51
    ~QueryQuark() {}
 
52
    QueryQuark& operator=(const QueryQuark& q);
 
53
    operator ustring() const;
 
54
 
 
55
    operator GQuark() const {return quark_;}
 
56
    GQuark id() const       {return quark_;}
 
57
 
 
58
  private:
 
59
    GQuark quark_;
 
60
};
 
61
 
 
62
class Quark: public QueryQuark
 
63
{
 
64
  public:
 
65
    Quark(const ustring& s);
 
66
    Quark(const char* s);
 
67
    ~Quark();
 
68
};
 
69
 
 
70
/** @relates Glib::QueryQuark */
 
71
inline bool operator==(const QueryQuark& a, const QueryQuark& b)
 
72
  { return a.id() == b.id(); }
 
73
 
 
74
/** @relates Glib::QueryQuark */
 
75
inline bool operator!=(const QueryQuark& a, const QueryQuark& b)
 
76
  { return a.id() != b.id(); }
 
77
 
 
78
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
79
// TODO: Put this somewhere else.
 
80
// (internal) The quark for C++ wrappers.
 
81
extern GLIBMM_API GQuark quark_;
 
82
extern GLIBMM_API GQuark quark_cpp_wrapper_deleted_;
 
83
#endif
 
84
 
 
85
} /* namespace Glib */
 
86
 
 
87
#endif /* _GLIBMM_QUARK_H */
 
88