當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Io_Writer::write方法代碼示例

本文整理匯總了PHP中Zend_Io_Writer::write方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Io_Writer::write方法的具體用法?PHP Zend_Io_Writer::write怎麽用?PHP Zend_Io_Writer::write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Io_Writer的用法示例。


在下文中一共展示了Zend_Io_Writer::write方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: writeMessageData

 /**
  * Writes a data-record to the file.
  * @param mixed[] $msg_def
  * @param mixed[] $message_data
  * @return \Fit\Writer
  */
 protected function writeMessageData($msg_def, $message_data)
 {
     $local_msg_type = $this->getLocalMsgType($msg_def['global_msg_number']);
     $this->writeRecordHeaderByte($local_msg_type, false);
     //en nu de velddata wegschrijven
     foreach ($msg_def['fields'] as $field_def) {
         if (isset($message_data[$field_def[\Fit\Field::NAME]])) {
             $val = $message_data[$field_def[\Fit\Field::NAME]];
         } else {
             $val = null;
         }
         if (is_numeric($val) && $field_def[\Fit\Field::FACTOR] > 0) {
             $val /= $field_def[\Fit\Field::FACTOR];
         }
         $big_endian = $msg_def['architecture'] === 1;
         switch ($field_def[\Fit\Field::TYPE_NUMBER]) {
             case \Fit\Core::STRING:
                 $this->writer->writeString8((string) $val, $field_def[\Fit\Field::SIZE]);
                 break;
             case \Fit\Core::SINT8:
                 $this->writer->writeInt8($val);
                 break;
             case \Fit\Core::ENUM:
             case \Fit\Core::UINT8Z:
             case \Fit\Core::UINT8:
                 $this->writer->writeUInt8($val);
                 break;
             case \Fit\Core::SINT16:
                 $big_endian ? $this->writer->writeInt16BE($val) : $this->writer->writeInt16LE($val);
                 break;
             case \Fit\Core::UINT16Z:
             case \Fit\Core::UINT16:
                 $big_endian ? $this->writer->writeUInt16BE($val) : $this->writer->writeUInt16LE($val);
                 break;
             case \Fit\Core::SINT32:
                 $big_endian ? $this->writer->writeInt32BE($val) : $this->writer->writeInt32LE($val);
                 break;
             case \Fit\Core::UINT32Z:
             case \Fit\Core::UINT32:
                 $big_endian ? $this->writer->writeUInt32BE($val) : $this->writer->writeUInt32LE($val);
                 break;
             case \Fit\Core::FLOAT32:
                 $big_endian ? $this->writer->writeFloatBE($val) : $this->writer->writeFloatLE($val);
                 break;
             case \Fit\Core::FLOAT64:
                 $big_endian ? $this->writer->writeInt64BE($val) : $this->writer->writeInt64LE($val);
                 break;
             case \Fit\Core::BYTE:
             default:
                 $this->writer->write($val, $field_def[\Fit\Field::SIZE]);
         }
     }
     return $this;
 }
開發者ID:alexmcroberts,項目名稱:fit-php,代碼行數:60,代碼來源:Writer.php

示例2: _writeData

 /**
  * Writes the frame raw data without the header.
  *
  * @param Zend_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     $writer->writeUInt8($this->_encoding);
     switch ($this->_encoding) {
         case self::UTF16LE:
             $writer->writeString16($this->_description, Zend_Io_Writer::LITTLE_ENDIAN_ORDER, 1);
             break;
         case self::UTF16:
             // break intentionally omitted
         // break intentionally omitted
         case self::UTF16BE:
             $writer->writeString16($this->_description, null, 1);
             break;
         default:
             $writer->writeString8($this->_description, 1);
             break;
     }
     $writer->write($this->_link);
 }
開發者ID:jreinert,項目名稱:RuneUI,代碼行數:25,代碼來源:Wxxx.php

示例3: _writeData

 /**
  * Writes the frame raw data without the header.
  *
  * @param Zend_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     $writer->write($this->_data);
 }
開發者ID:google-code-backups,項目名稱:php-reader,代碼行數:10,代碼來源:Mcdi.php

示例4: _writeData

 /**
  * Writes the frame raw data without the header.
  *
  * @param Zend_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     $writer->writeUInt8($this->_encoding);
     switch ($this->_encoding) {
         case self::UTF16LE:
             $count = count($this->_text);
             for ($i = 0; $i < $count; $i++) {
                 $writer->writeString16($this->_text, Zend_Io_Writer::LITTLE_ENDIAN_ORDER, $i == $count ? null : 1);
             }
             break;
         case self::UTF16:
             // break intentionally omitted
         // break intentionally omitted
         case self::UTF16BE:
             $writer->write(implode("", $this->_text));
             break;
         default:
             $writer->write(implode("", $this->_text));
             break;
     }
 }
開發者ID:google-code-backups,項目名稱:php-reader,代碼行數:27,代碼來源:TextFrame.php

示例5: write

 /**
  * Writes the header data.
  *
  * @param Zend_Io_Writer $writer The writer object.
  * @return void
  */
 public function write($writer)
 {
     /* ID3v2.3.0 ExtendedHeader */
     if ($this->getOption('version', 4) < 4) {
         $writer->writeUInt32BE($this->_size)->writeUInt16BE($this->hasFlag(self::CRC32) ? 0x8000 : 0)->writeUInt32BE($this->_padding);
         if ($this->hasFlag(self::CRC32)) {
             $writer->writeUInt32BE($this->_crc);
         }
     } else {
         $writer->writeUInt32BE($this->_encodeSynchsafe32($this->_size))->writeInt8(1)->writeInt8($this->_flags);
         if ($this->hasFlag(self::UPDATE)) {
             $writer->write("");
         }
         if ($this->hasFlag(self::CRC32)) {
             $writer->writeInt8(5)->writeInt8($this->_crc & 4026531840.0 >> 28 & 0xf)->writeUInt32BE($this->_encodeSynchsafe32($this->_crc));
         }
         if ($this->hasFlag(self::RESTRICTED)) {
             $writer->writeInt8(1)->writeInt8($this->_restrictions);
         }
     }
 }
開發者ID:halbo5,項目名稱:com_muzeetop_j16,代碼行數:27,代碼來源:ExtendedHeader.php

示例6: _writeData

 /**
  * Writes the frame raw data without the header.
  *
  * @param Zend_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     $tmp = new Zend_Io_StringWriter();
     $tmp->writeUInt32BE($this->_bufferSize);
     $writer->write(substr($tmp->toString(), 1, 3))->writeInt8($this->_infoFlags)->writeInt32BE($this->_offset);
 }
開發者ID:adam-fonseca,項目名稱:RuneUI,代碼行數:12,代碼來源:Rbuf.php

示例7: _writeData

 /**
  * Writes the frame raw data without the header.
  *
  * @param Zend_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     $writer->writeUInt8($this->_encoding)->write($this->_language);
     switch ($this->_encoding) {
         case self::UTF16LE:
             $writer->writeString16($this->_text, Zend_Io_Writer::LITTLE_ENDIAN_ORDER);
             break;
         case self::UTF16:
             // break intentionally omitted
         // break intentionally omitted
         case self::UTF16BE:
             // break intentionally omitted
         // break intentionally omitted
         default:
             $writer->write($this->_text);
             break;
     }
 }
開發者ID:google-code-backups,項目名稱:php-reader,代碼行數:24,代碼來源:LanguageTextFrame.php

示例8: _writeData

 /**
  * Writes the tag data.
  *
  * @param Zend_Io_Writer $writer The writer object.
  * @return void
  */
 private function _writeData($writer)
 {
     $this->clearOption('unsynchronisation');
     $buffer = new Zend_Io_StringWriter();
     foreach ($this->_frames as $frames) {
         foreach ($frames as $frame) {
             $frame->write($buffer);
         }
     }
     $frameData = $buffer->toString();
     $frameDataLength = strlen($frameData);
     $paddingLength = 0;
     // ID3v2.4.0 supports frame level unsynchronisation while
     // ID3v2.3.0 supports only tag level unsynchronisation.
     if ($this->getOption('version', 4) < 4 && $this->getOption('compat', false) !== true) {
         $frameData = $this->_encodeUnsynchronisation($frameData);
         if (($len = strlen($frameData)) != $frameDataLength) {
             $frameDataLength = $len;
             $this->_header->setFlags($this->_header->getFlags() | Zend_Media_Id3_Header::UNSYNCHRONISATION);
         } else {
             $this->_header->setFlags($this->_header->getFlags() & ~Zend_Media_Id3_Header::UNSYNCHRONISATION);
         }
     }
     // The tag padding is calculated as follows. If the tag can be written
     // in the space of the previous tag, the remaining space is used for
     // padding. If there is no previous tag or the new tag is bigger than
     // the space taken by the previous tag, the padding is a constant
     // 4096 bytes.
     if ($this->hasFooter() === false) {
         if ($this->_reader !== null && $frameDataLength < $this->_header->getSize()) {
             $paddingLength = $this->_header->getSize() - $frameDataLength;
         } else {
             $paddingLength = 4096;
         }
     }
     /* ID3v2.4.0 CRC calculated w/ padding */
     if ($this->getOption('version', 4) >= 4) {
         $frameData = str_pad($frameData, $frameDataLength += $paddingLength, "");
     }
     $extendedHeaderData = '';
     $extendedHeaderDataLength = 0;
     if ($this->hasExtendedHeader()) {
         $this->_extendedHeader->setPadding($paddingLength);
         if ($this->_extendedHeader->hasFlag(Zend_Media_Id3_ExtendedHeader::CRC32)) {
             $crc = crc32($frameData);
             if ($crc & 0x80000000) {
                 $crc = -(($crc ^ 0xffffffff) + 1);
             }
             $this->_extendedHeader->setCrc($crc);
         }
         $buffer = new Zend_Io_StringWriter();
         $this->_extendedHeader->write($buffer);
         $extendedHeaderData = $buffer->toString();
         $extendedHeaderDataLength = strlen($extendedHeaderData);
     }
     /* ID3v2.3.0 CRC calculated w/o padding */
     if ($this->getOption('version', 4) < 4) {
         $frameData = str_pad($frameData, $frameDataLength += $paddingLength, "");
     }
     $this->_header->setSize($extendedHeaderDataLength + $frameDataLength);
     $writer->write('ID3');
     $this->_header->write($writer);
     $writer->write($extendedHeaderData);
     $writer->write($frameData);
     if ($this->hasFooter()) {
         $writer->write('3DI');
         $this->_footer->write($writer);
     }
 }
開發者ID:lokamaya,項目名稱:zend-mp3,代碼行數:75,代碼來源:Id3v2.php

示例9: write

 /**
  * Writes the frame data with the header.
  *
  * @param Zend_Io_Writer $writer The writer object.
  * @return void
  */
 public function write($writer)
 {
     /* ID3v2.3.0 Flags; convert from 2.4.0 format */
     if ($this->getOption('version', 4) < 4) {
         $flags = 0;
         if ($this->hasFlag(self::DISCARD_ON_TAGCHANGE)) {
             $flags = $flags | 0x8000;
         }
         if ($this->hasFlag(self::DISCARD_ON_FILECHANGE)) {
             $flags = $flags | 0x4000;
         }
         if ($this->hasFlag(self::READ_ONLY)) {
             $flags = $flags | 0x2000;
         }
         if ($this->hasFlag(self::COMPRESSION)) {
             $flags = $flags | 0x80;
         }
         if ($this->hasFlag(self::ENCRYPTION)) {
             $flags = $flags | 0x40;
         }
         if ($this->hasFlag(self::GROUPING_IDENTITY)) {
             $flags = $flags | 0x20;
         }
     } else {
         $flags = $this->_flags;
     }
     $this->_writeData($buffer = new Zend_Io_StringWriter());
     $data = $buffer->toString();
     $size = $this->_size = strlen($data);
     // ID3v2.4.0 supports frame level unsynchronisation. The corresponding
     // option is set to true when any of the frames use the
     // unsynchronisation scheme. The usage is denoted by
     // Zend_Media_Id3_Header flag that is set accordingly upon file write.
     if ($this->getOption('version', 4) >= 4) {
         $data = $this->_encodeUnsynchronisation($data);
         if (($dataLength = strlen($data)) != $size) {
             $size = 4 + $dataLength;
             $flags |= self::DATA_LENGTH_INDICATOR | self::UNSYNCHRONISATION;
             $this->setOption('unsynchronisation', true);
         } else {
             $flags &= ~(self::DATA_LENGTH_INDICATOR | self::UNSYNCHRONISATION);
         }
     }
     $writer->writeString8(substr($this->_identifier, 0, 4), 4, " ")->writeUInt32BE($this->getOption('version', 4) < 4 ? $size : $this->_encodeSynchsafe32($size))->writeUInt16BE($flags);
     if (($flags & self::DATA_LENGTH_INDICATOR) == self::DATA_LENGTH_INDICATOR) {
         $writer->writeUInt32BE($this->getOption('version', 4) < 4 ? $this->_size : $this->_encodeSynchsafe32($this->_size));
     }
     $writer->write($data);
 }
開發者ID:adam-fonseca,項目名稱:RuneUI,代碼行數:55,代碼來源:Frame.php

示例10: _writeData

 /**
  * Writes the box header. Subclasses should overwrite this method and call
  * the parent method first and then write the box related data.
  *
  * @param Zend_Io_Writer $writer The writer object.
  * @return void
  */
 protected function _writeData($writer)
 {
     if (get_class($this) == "Zend_Media_Iso14496_Box") {
         require_once 'Zend/Media/Iso14496/Exception.php';
         throw new Zend_Media_Iso14496_Exception('Unknown box \'' . $this->getType() . '\' cannot be written.');
     }
     $this->_size = $this->getHeapSize();
     if ($this->_size > 4294967295.0) {
         $writer->writeUInt32BE(1);
     } else {
         $writer->writeUInt32BE($this->_size);
     }
     if (strlen($this->_type) > 4) {
         $writer->write('uuid');
     } else {
         $writer->write($this->_type);
     }
     if ($this->_size > 4294967295.0) {
         $writer->writeInt64BE($this->_size);
     }
     if (strlen($this->_type) > 4) {
         $writer->writeGuid($this->_type);
     }
 }
開發者ID:andreiamfg,項目名稱:MobileWebHybrid,代碼行數:31,代碼來源:Box.php


注:本文中的Zend_Io_Writer::write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。