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/header.h"
18
19 namespace sfntly {
20
21 /******************************************************************************
22 * Header class
23 ******************************************************************************/
Header(int32_t tag)24 Header::Header(int32_t tag)
25 : tag_(tag),
26 offset_(0),
27 offset_valid_(false),
28 length_(0),
29 length_valid_(false),
30 checksum_(0),
31 checksum_valid_(false) {
32 }
33
Header(int32_t tag,int32_t length)34 Header::Header(int32_t tag, int32_t length)
35 : tag_(tag),
36 offset_(0),
37 offset_valid_(false),
38 length_(length),
39 length_valid_(true),
40 checksum_(0),
41 checksum_valid_(false) {
42 }
43
Header(int32_t tag,int64_t checksum,int32_t offset,int32_t length)44 Header::Header(int32_t tag, int64_t checksum, int32_t offset, int32_t length)
45 : tag_(tag),
46 offset_(offset),
47 offset_valid_(true),
48 length_(length),
49 length_valid_(true),
50 checksum_(checksum),
51 checksum_valid_(true) {
52 }
53
~Header()54 Header::~Header() {}
55
operator ()(const HeaderPtr lhs,const HeaderPtr rhs) const56 bool HeaderComparatorByOffset::operator() (const HeaderPtr lhs,
57 const HeaderPtr rhs) const {
58 return lhs->offset_ > rhs->offset_;
59 }
60
operator ()(const HeaderPtr lhs,const HeaderPtr rhs) const61 bool HeaderComparatorByTag::operator() (const HeaderPtr lhs,
62 const HeaderPtr rhs) const {
63 return lhs->tag_ > rhs->tag_;
64 }
65
66 } // namespace sfntly
67