コード例 #1
0
ファイル: dumper.php プロジェクト: pmolfese/nidb
 /**
  * Internal method for dumping
  *
  * @param	object	 the dataset
  * @param	string	 the spacer
  * @return	string	 the dumped dataset
  */
 protected function _dump($dataset, $spacer = '')
 {
     $out = '';
     foreach ($dataset as $group => $elements) {
         // Load dictionaries (Forced loading)
         Nanodicom_Dictionary::load_dictionary($group, TRUE);
         foreach ($elements as $element => $indexes) {
             foreach ($indexes as $values) {
                 $elem = $values;
                 $elem['g'] = $group;
                 $elem['e'] = $element;
                 if (!isset($elem['done'])) {
                     // Read value if not read yet
                     $this->_read_value_from_blob($elem, $group, $element);
                 }
                 // Indent back when a delimiter was found. Must be done before dumping.
                 if ($group == Nanodicom::ITEMS_GROUP and in_array($element, array(Nanodicom::ITEM_DELIMITER, Nanodicom::SEQUENCE_DELIMITER))) {
                     $spacer = substr($spacer, 0, -1 * strlen($this->output['spacer']));
                 }
                 // Start the dataset and dump the current element
                 $out .= $this->output['dataset_begin'] . $this->_dump_element($elem, $spacer);
                 if (count($elem['ds']) > 0) {
                     // Take care of items
                     $out .= $this->_dump($elem['ds'], $spacer . $this->output['spacer']);
                 }
                 // Close the dataset
                 $out .= $this->output['dataset_end'];
             }
             unset($values);
         }
         unset($element, $indexes);
     }
     unset($group, $elements);
     return $out;
 }
コード例 #2
0
ファイル: core.php プロジェクト: pmolfese/nidb
 /**
  * Read the value from the blob
  *
  * @param	object	 the element array
  * @param	integer	 the group
  * @param	integer	 the element
  * @return	void
  */
 protected function _read_value_from_blob(&$elem, $group, $element)
 {
     // Load dictionaries (Forced loading)
     Nanodicom_Dictionary::load_dictionary($group, TRUE);
     // Save current pointer
     $current_pointer = $this->_tell();
     // Values have not been read
     $this->_rewind($elem['_off']);
     // Decode the right VR.
     list($elem['vr'], $multiplicity, $name) = $this->_decode_vr($group, $element, $elem['_vr'], $elem['len']);
     // Read the value
     list($elem['val'], $elem['vr'], $elem['bin'], $elem['ds']) = $this->_read_value($elem['_vr'], $elem['vr'], $elem['len'], $this->_transfer_syntax);
     // Element has been read. Set to true
     $elem['done'] = TRUE;
     // Rewind to previous pointer, we just read and returned everything back to normal
     $this->_rewind($current_pointer);
 }