aboutsummaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/tree/facet.hxx
blob: f2452da44729fa8e7eb95a4b4a02674a5881f144 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// file      : xsd/cxx/tree/facet.hxx
// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

#ifndef XSD_CXX_TREE_FACET_HXX
#define XSD_CXX_TREE_FACET_HXX

namespace xsd
{
  namespace cxx
  {
    namespace tree
    {
      // We need to keep this type POD in order to be able to create a
      // static array.
      //
      struct facet
      {
        enum id_type
        {
          none,
          total_digits,
          fraction_digits
        };

        id_type id;
        unsigned long value;

        static const facet*
        find (const facet* facets, facet::id_type id)
        {
          while (facets->id != id && facets->id != none)
            ++facets;

          return facets->id != none ? facets : 0;
        }
      };
    }
  }
}

#endif  // XSD_CXX_TREE_FACET_HXX