16b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com/*
26b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com * Copyright 2011 Google Inc. All Rights Reserved.
36b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com *
46b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com * Licensed under the Apache License, Version 2.0 (the "License");
56b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com * you may not use this file except in compliance with the License.
66b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com * You may obtain a copy of the License at
76b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com *
86b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com *      http://www.apache.org/licenses/LICENSE-2.0
96b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com *
106b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com * Unless required by applicable law or agreed to in writing, software
116b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com * distributed under the License is distributed on an "AS IS" BASIS,
126b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
136b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com * See the License for the specific language governing permissions and
146b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com * limitations under the License.
156b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com */
166b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com
176b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com#include "sfntly/table/header.h"
186b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com
196b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.comnamespace sfntly {
206b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com
216b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com/******************************************************************************
226b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com * Header class
236b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com ******************************************************************************/
246b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.comHeader::Header(int32_t tag)
256b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com    : tag_(tag),
266b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      offset_(0),
276b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      offset_valid_(false),
286b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      length_(0),
296b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      length_valid_(false),
306b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      checksum_(0),
316b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      checksum_valid_(false) {
326b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com}
336b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com
346b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.comHeader::Header(int32_t tag, int32_t length)
356b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com    : tag_(tag),
366b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      offset_(0),
376b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      offset_valid_(false),
386b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      length_(length),
396b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      length_valid_(true),
406b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      checksum_(0),
416b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      checksum_valid_(false) {
426b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com}
436b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com
446b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.comHeader::Header(int32_t tag, int64_t checksum, int32_t offset, int32_t length)
456b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com    : tag_(tag),
466b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      offset_(offset),
476b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      offset_valid_(true),
486b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      length_(length),
496b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      length_valid_(true),
506b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      checksum_(checksum),
516b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com      checksum_valid_(true) {
526b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com}
536b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com
546b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.comHeader::~Header() {}
556b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com
566b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.combool HeaderComparatorByOffset::operator() (const HeaderPtr lhs,
576b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com                                           const HeaderPtr rhs) {
586b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  return lhs->offset_ > rhs->offset_;
596b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com}
606b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com
616b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.combool HeaderComparatorByTag::operator() (const HeaderPtr lhs,
626b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com                                        const HeaderPtr rhs) {
636b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com  return lhs->tag_ > rhs->tag_;
646b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com}
656b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com
666b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com}  // namespace sfntly
67