~ubuntu-branches/ubuntu/oneiric/mozc/oneiric

« back to all changes in this revision

Viewing changes to converter/converter_data.cc

  • Committer: Bazaar Package Importer
  • Author(s): Nobuhiro Iwamatsu
  • Date: 2010-07-14 03:26:47 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100714032647-13qjisj6m8cm8jdx
Tags: 0.12.410.102-1
* New upstream release (Closes: #588971).
  - Add mozc-server, mozc-utils-gui and scim-mozc packages.
* Update debian/rules.
  Add --gypdir option to build_mozc.py.
* Update debian/control.
  - Bumped standards-version to 3.9.0.
  - Update description.
* Add mozc icon (Closes: #588972).
* Add patch which revises issue 18.
  ibus_mozc_issue18.patch
* kFreeBSD build support.
  support_kfreebsd.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2010, Google Inc.
2
 
// All rights reserved.
3
 
//
4
 
// Redistribution and use in source and binary forms, with or without
5
 
// modification, are permitted provided that the following conditions are
6
 
// met:
7
 
//
8
 
//     * Redistributions of source code must retain the above copyright
9
 
// notice, this list of conditions and the following disclaimer.
10
 
//     * Redistributions in binary form must reproduce the above
11
 
// copyright notice, this list of conditions and the following disclaimer
12
 
// in the documentation and/or other materials provided with the
13
 
// distribution.
14
 
//     * Neither the name of Google Inc. nor the names of its
15
 
// contributors may be used to endorse or promote products derived from
16
 
// this software without specific prior written permission.
17
 
//
18
 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
 
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
 
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
 
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
 
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
 
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
 
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
 
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
 
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
 
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 
 
30
 
#include "converter/converter_data.h"
31
 
 
32
 
#include <cstring>
33
 
#include "base/base.h"
34
 
#include "converter/key_corrector.h"
35
 
 
36
 
namespace mozc {
37
 
 
38
 
ConverterData::ConverterData(): bos_node_(NULL),
39
 
                                eos_node_(NULL),
40
 
                                key_corrector_(new KeyCorrector),
41
 
                                node_freelist_(1024),
42
 
                                max_nodes_size_(8192) {}
43
 
 
44
 
ConverterData::~ConverterData() {}
45
 
 
46
 
Node *ConverterData::NewNode() {
47
 
  Node *node = node_freelist_.Alloc();
48
 
  node->Init();
49
 
  return node;
50
 
}
51
 
 
52
 
Node **ConverterData::begin_nodes_list() {
53
 
  return &begin_nodes_list_[0];
54
 
}
55
 
 
56
 
Node **ConverterData::end_nodes_list() {
57
 
  return &end_nodes_list_[0];
58
 
}
59
 
 
60
 
const KeyCorrector &ConverterData::key_corrector() const {
61
 
  return *(key_corrector_.get());
62
 
}
63
 
 
64
 
void ConverterData::set_key(const string &key,
65
 
                            KeyCorrector::InputMode mode) {
66
 
  key_ = key;
67
 
  const size_t size = key.size();
68
 
  begin_nodes_list_.resize(size + 4);
69
 
  end_nodes_list_.resize(size + 4);
70
 
  fill(begin_nodes_list_.begin(), begin_nodes_list_.end(),
71
 
       static_cast<Node *>(NULL));
72
 
  fill(end_nodes_list_.begin(), end_nodes_list_.end(),
73
 
       static_cast<Node *>(NULL));
74
 
  key_corrector_->CorrectKey(key, mode);
75
 
}
76
 
 
77
 
const string &ConverterData::key() const {
78
 
  return key_;
79
 
}
80
 
 
81
 
bool ConverterData::has_lattice() const {
82
 
  return !begin_nodes_list_.empty();
83
 
}
84
 
 
85
 
void ConverterData::clear_lattice() {
86
 
  key_.clear();
87
 
  begin_nodes_list_.clear();
88
 
  end_nodes_list_.clear();
89
 
  node_freelist_.Free();
90
 
}
91
 
}  // namespace mozc