~ubuntu-branches/ubuntu/vivid/libe-book/vivid-proposed

« back to all changes in this revision

Viewing changes to src/lib/FB2Token.cpp

  • Committer: Package Import Robot
  • Author(s): Rene Engelhard
  • Date: 2014-08-07 23:08:06 UTC
  • mfrom: (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20140807230806-o06a0n2dspjavqfm
Tags: 0.1.1-2
* upload to unstable

* fix debian/copyright; this is MPL-2.0 only 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
 
/* libe-book
3
 
 * Version: MPL 2.0 / LGPLv2.1+
 
2
/*
 
3
 * This file is part of the libe-book project.
4
4
 *
5
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 
 *
9
 
 * Alternatively, the contents of this file may be used under the terms
10
 
 * of the GNU Lesser General Public License Version 2.1 or later
11
 
 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
12
 
 * applicable instead of those above.
13
 
 *
14
 
 * For further information visit http://libebook.sourceforge.net
15
8
 */
16
9
 
17
10
#include <cstring>
33
26
namespace libebook
34
27
{
35
28
 
36
 
const EBOOKToken *getFB2Token(const char *const str, const unsigned length)
 
29
const FB2TokenData *getFB2Token(const char *const str, const unsigned length)
37
30
{
38
31
  if (!str)
39
32
    return 0;
40
 
  return reinterpret_cast<const EBOOKToken *>(Perfect_Hash::in_word_set(str, length));
 
33
  return reinterpret_cast<const FB2TokenData *>(Perfect_Hash::in_word_set(str, length));
41
34
}
42
35
 
43
 
const EBOOKToken *getFB2Token(const char *const str)
 
36
const FB2TokenData *getFB2Token(const char *const str)
44
37
{
45
38
  if (!str)
46
39
    return 0;
47
40
  return getFB2Token(str, strlen(str));
48
41
}
49
42
 
50
 
const EBOOKToken *getFB2Token(const unsigned char *const str)
 
43
const FB2TokenData *getFB2Token(const unsigned char *const str)
51
44
{
52
45
  if (!str)
53
46
    return 0;
54
47
  return getFB2Token(reinterpret_cast<const char *>(str));
55
48
}
56
49
 
57
 
int getFB2TokenID(const EBOOKToken &token)
 
50
int getFB2TokenID(const FB2TokenData &token)
58
51
{
59
52
  return getFB2TokenID(&token);
60
53
}
61
54
 
62
 
int getFB2TokenID(const EBOOKToken *const token)
 
55
int getFB2TokenID(const FB2TokenData *const token)
63
56
{
64
57
  return token ? token->id : INVALID_TOKEN;
65
58
}
79
72
  return getFB2TokenID(reinterpret_cast<const char *>(str));
80
73
}
81
74
 
82
 
const char *getFB2TokenName(const EBOOKToken &token)
 
75
const char *getFB2TokenName(const FB2TokenData &token)
83
76
{
84
77
  return getFB2TokenName(&token);
85
78
}
86
79
 
87
 
const char *getFB2TokenName(const EBOOKToken *const token)
 
80
const char *getFB2TokenName(const FB2TokenData *const token)
88
81
{
89
82
  return token ? token->name : 0;
90
83
}