LCOV - code coverage report
Current view: top level - gfx/sfntly/cpp/src/sfntly/data - font_output_stream.cc (source / functions) Hit Total Coverage
Test: output.info Lines: 0 71 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 17 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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/data/font_output_stream.h"
      18             : 
      19             : #include <algorithm>
      20             : 
      21             : namespace sfntly {
      22             : 
      23           0 : FontOutputStream::FontOutputStream(OutputStream* os)
      24             :     : stream_(os),
      25           0 :       position_(0) {
      26           0 : }
      27             : 
      28           0 : FontOutputStream::~FontOutputStream() {
      29             :   // Do not close, underlying stream shall clean up themselves.
      30           0 : }
      31             : 
      32           0 : void FontOutputStream::Write(byte_t b) {
      33           0 :   if (stream_) {
      34           0 :     stream_->Write(b);
      35           0 :     position_++;
      36             :   }
      37           0 : }
      38             : 
      39           0 : void FontOutputStream::Write(ByteVector* b) {
      40           0 :   if (b) {
      41           0 :     Write(b, 0, b->size());
      42           0 :     position_ += b->size();
      43             :   }
      44           0 : }
      45             : 
      46           0 : void FontOutputStream::Write(ByteVector* b, int32_t off, int32_t len) {
      47           0 :   assert(b);
      48           0 :   assert(stream_);
      49           0 :   if (off < 0 || len < 0 || off + len < 0 ||
      50           0 :       static_cast<size_t>(off + len) > b->size()) {
      51             : #if !defined (SFNTLY_NO_EXCEPTION)
      52             :     throw IndexOutOfBoundException();
      53             : #else
      54           0 :     return;
      55             : #endif
      56             :   }
      57             : 
      58           0 :   stream_->Write(b, off, len);
      59           0 :   position_ += len;
      60             : }
      61             : 
      62           0 : void FontOutputStream::Write(byte_t* b, int32_t off, int32_t len) {
      63           0 :   assert(b);
      64           0 :   assert(stream_);
      65           0 :   if (off < 0 || len < 0 || off + len < 0) {
      66             : #if !defined (SFNTLY_NO_EXCEPTION)
      67             :     throw IndexOutOfBoundException();
      68             : #else
      69           0 :     return;
      70             : #endif
      71             :   }
      72             : 
      73           0 :   stream_->Write(b, off, len);
      74           0 :   position_ += len;
      75             : }
      76             : 
      77           0 : void FontOutputStream::WriteChar(byte_t c) {
      78           0 :   Write(c);
      79           0 : }
      80             : 
      81           0 : void FontOutputStream::WriteUShort(int32_t us) {
      82           0 :   Write((byte_t)((us >> 8) & 0xff));
      83           0 :   Write((byte_t)(us & 0xff));
      84           0 : }
      85             : 
      86           0 : void FontOutputStream::WriteShort(int32_t s) {
      87           0 :   WriteUShort(s);
      88           0 : }
      89             : 
      90           0 : void FontOutputStream::WriteUInt24(int32_t ui) {
      91           0 :   Write((byte_t)(ui >> 16) & 0xff);
      92           0 :   Write((byte_t)(ui >> 8) & 0xff);
      93           0 :   Write((byte_t)ui & 0xff);
      94           0 : }
      95             : 
      96           0 : void FontOutputStream::WriteULong(int64_t ul) {
      97           0 :   Write((byte_t)((ul >> 24) & 0xff));
      98           0 :   Write((byte_t)((ul >> 16) & 0xff));
      99           0 :   Write((byte_t)((ul >> 8) & 0xff));
     100           0 :   Write((byte_t)(ul & 0xff));
     101           0 : }
     102             : 
     103           0 : void FontOutputStream::WriteLong(int64_t l) {
     104           0 :   WriteULong(l);
     105           0 : }
     106             : 
     107           0 : void FontOutputStream::WriteFixed(int32_t f) {
     108           0 :   WriteULong(f);
     109           0 : }
     110             : 
     111           0 : void FontOutputStream::WriteDateTime(int64_t date) {
     112           0 :   WriteULong((date >> 32) & 0xffffffff);
     113           0 :   WriteULong(date & 0xffffffff);
     114           0 : }
     115             : 
     116           0 : void FontOutputStream::Flush() {
     117           0 :   if (stream_) {
     118           0 :     stream_->Flush();
     119             :   }
     120           0 : }
     121             : 
     122           0 : void FontOutputStream::Close() {
     123           0 :   if (stream_) {
     124           0 :     stream_->Flush();
     125           0 :     stream_->Close();
     126           0 :     position_ = 0;
     127             :   }
     128           0 : }
     129             : 
     130             : }  // namespace sfntly

Generated by: LCOV version 1.13