| Новости | FAQ | Авторы | Документация | В действии | Библиотека |
| Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
AleXp 04.10.2005 03:10
Накосячил в @debugShowTable[] с таблицами nameless, но тем не менее работает.###################################################################################################
# $Id: visualization.p,v 1.0 2005/09/28 06:30:21 1 Exp $
###################################################################################################
#
# @debugShowObject[] Визуализация объектов
# @debugShowVoid[] Визуализация пустых объектов
# @debugShowString[] Визуализация объекта класса string
# @debugShowTable[] Визуализация объекта класса table
# @debugShowImage[] Визуализация объекта класса image
# @debugShowDate[] Визуализация объекта класса date
# @debugShowFile[] Визуализация объекта класса file
# @debugShowDouble[] Визуализация объекта класса int или double
# @debugShowBool[] Визуализация объекта класса bool
# @debugShowHash[] Визуализация объекта класса hash
#
###################################################################################################
@debugShowObject[object]
###################################################################################################
# Визуализация объектов
#
# string
# debugShowObject[
# undefined object
# ]
#
^if(!def $object){
^debugShowVoid[$object]
}{
^if($object is date){^debugShowDate[$object]}
^if($object is file){^debugShowFile[$object]}
^if($object is image){^debugShowImage[$object]}
^if($object is bool){^debugShowBool[$object]}
^if($object is table){^debugShowTable[$object]}
^if($object is string){^debugShowString[$object]}
^if($object is int || $object is double){^debugShowDouble[$object]}
^if($object is hash){^debugShowHash[$object]}
}
#end @debugShowObject[]
@debugShowString[text]
###################################################################################################
# Визуализация объекта класса string
#
# string
# debugShowString[
# string text
# ]
#
$result[<strong>$text</strong> (string)<br>]
#end @debugShowString[]
@debugShowDouble[d]
###################################################################################################
# Визуализация объекта класса int или double
#
# string
# debugShowDouble[
# int/double d
# ]
#
$result[<strong>$d</strong> (int/double)<br>]
#end @debugShowDouble[]
@debugShowBool[b]
###################################################################################################
# Визуализация объекта класса bool
#
# string
# debugShowBool[
# bool b
# ]
#
$result[<strong>^if($b){true}{false}</strong> (bool)<br>]
#end @debugShowBool[]
@debugShowVoid[v]
###################################################################################################
# Визуализация пустых объектов
#
# string
# debugShowVoid[
# void v
# ]
#
$result[<strong>Значение не присвоено</strong> (void)<br>]
#end @debugShowVoid[]
@debugShowFile[f][_f]
###################################################################################################
# Визуализация объекта класса file
#
# string
# debugShowFile[
# file f
# ]
#
^try{
$_f[^file::stat[$f.name]]
$result[<strong>^file:fullpath[$f.name]</strong> (file).<br>
 ^; ^; ^; ^; ^; ^; ^; ^; ^;Размер: $_f.size байт.<br>
 ^; ^; ^; ^; ^; ^; ^; ^; ^;Создан ${_f.cdate.day}.${_f.cdate.month}.${_f.cdate.year} в ${_f.cdate.hour}ч.${_f.cdate.minute}мин.<br>
 ^; ^; ^; ^; ^; ^; ^; ^; ^;Изменен: ${_f.mdate.day}.${_f.mdate.month}.${_f.mdate.year} в ${_f.mdate.hour}ч.${_f.mdate.minute}мин.<br>
 ^; ^; ^; ^; ^; ^; ^; ^; ^;Последний раз обращение к файлу производилось ${_f.adate.day}.${_f.adate.month}.${_f.adate.year} в ${_f.adate.hour}ч.${_f.adate.minute}мин.<br>
 ^; ^; ^; ^; ^; ^; ^; ^; ^;MIME-тип файла: $_f.content-type<br>
^if(${_f.content-type} eq "text/plain" || ${_f.content-type} eq "text/html"){
 ^; ^; ^; ^; ^; ^; ^; ^; ^;Первые 100 символов файла:<br>
 ^; ^; ^; ^; ^; ^; ^; ^; ^;<strong>^f.text.left(100)...>>></strong><br>
 ^; ^; ^; ^; ^; ^; ^; ^; ^;Последние 100 символов файла:<br>
 ^; ^; ^; ^; ^; ^; ^; ^; ^;<strong><<<...^f.text.right(100)</strong><br>
}
]
}{
$exception.handled(1)
$result[<font color="red"><strong>^file:fullpath[$f.name]</strong> (file) не найден!</font><br>]
}
#end @debugShowFile[]
@debugShowDate[d]
###################################################################################################
# Визуализация объекта класса date
#
# string
# debugShowDate[
# date d
# ]
#
$result[<strong>${d.day}.${d.month}.${d.year}, ${d.hour}ч.${d.minute}мин.${d.second}сек. $d.yearday день года</strong> (date)<br>]
#end @debugShowDate[]
@debugShowImage[i]
###################################################################################################
# Визуализация объектов класса image
#
# string
# debugShowImage[
# image i
# ]
#
$result[^if(def $i.src){<strong>^i.html[]</strong>}{<strong>Графический объект созданный Parser3</strong>} (image)<br>
Высота изображения^: $i.height<br>
Ширина изображения^: $i.width
^if(def $i.exif){^debugShowHash[$i.exif]}]
#end @debugShowImage[]
@debugShowTable[t][_tcol;_t;_path]
###################################################################################################
# Визуализация объектов класса table
#
# string
# debugShowTable[
# table t
# ]
#
^if(^t.columns[] != ^t.flip[]){
$_path[$TEMP_DIR/^math:uid64[]]
^t.save[$_path]
$_t[^table::load[$_path]]
^file:delete[$_path]
Объект является nameless таблицей!<br>
^debugShowTable[$_t]
}{
$_tcol[^t.columns[]]
$result[<table cellSpacing="1" cellPadding="1" border="1">
<tr>
^_tcol.menu{
<td align="center"><strong>$_tcol.column</strong></td>
}
</tr>
^t.menu{
<tr>
^_tcol.menu{
<td align="center">$t.[$_tcol.column]</td>
}
</tr>
}
</table>]
}
#end @debugShowTable[]
@debugShowHash[h][k;v;_s]
###################################################################################################
# Визуализация объекта класса hash
#
# string
# debugShowHash[
# hash h
# ]
#
<br>
$self._s[$self._s ^; ^; ^; ^; ^; ^; ^; ^; ^; ^; ^; ^; ]
^h.foreach[k;v]{
^if(!def $v){$self._s^$.$k = ^debugShowVoid[$v]}
^if($v is bool){$self._s^$.$k = ^debugShowBool[$v]}
^if($v is string){$self._s^$.$k = ^debugShowString[$v]}
^if($v is int || $v is double){$self._s^$.$k = ^debugShowDouble($v)}
^if($v is hash){
$self._s^$.$k (hash) = ^debugShowHash[$v]
$self._s[^self._s.mid(^eval(^self._s.pos[ ]+1))]
}
}
#end @debugShowHash[]