1/*
2 * Copyright 2011 Google Inc. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "sfntly/table/byte_array_table_builder.h"
18
19namespace sfntly {
20
21ByteArrayTableBuilder::~ByteArrayTableBuilder() {}
22
23int32_t ByteArrayTableBuilder::ByteValue(int32_t index) {
24  ReadableFontDataPtr data = InternalReadData();
25  if (data == NULL) {
26#if !defined (SFNTLY_NO_EXCEPTION)
27    throw IOException("No font data for the table");
28#endif
29    return -1;
30  }
31  return data->ReadByte(index);
32}
33
34void ByteArrayTableBuilder::SetByteValue(int32_t index, byte_t b) {
35  WritableFontDataPtr data = InternalWriteData();
36  if (data == NULL) {
37#if !defined (SFNTLY_NO_EXCEPTION)
38    throw IOException("No font data for the table");
39#endif
40    return;
41  }
42  data->WriteByte(index, b);
43}
44
45int32_t ByteArrayTableBuilder::ByteCount() {
46  ReadableFontDataPtr data = InternalReadData();
47  if (data == NULL) {
48#if !defined (SFNTLY_NO_EXCEPTION)
49    throw IOException("No font data for the table");
50#endif
51    return 0;
52  }
53  return data->Length();
54}
55
56ByteArrayTableBuilder::ByteArrayTableBuilder(Header* header,
57                                               WritableFontData* data)
58    : TableBasedTableBuilder(header, data) {
59}
60
61ByteArrayTableBuilder::ByteArrayTableBuilder(Header* header,
62                                               ReadableFontData* data)
63    : TableBasedTableBuilder(header, data) {
64}
65
66ByteArrayTableBuilder::ByteArrayTableBuilder(Header* header)
67    : TableBasedTableBuilder(header) {
68}
69
70}  // namespace sfntly
71