parser

Написать ответ на текущее сообщение

 

 
   команды управления поиском

Куда выложить класс?

freeZZZ 21.04.2017 16:45

Сам исправил методы:
@_sql[hOption;jQuery][sFileSpec]
$sFileSpec[^self._getFileSpec[$hOption]]
^switch[^self._getFileStatus[$sFileSpec;$hOption]]{
	^case[load]{
		$caller.result[^self._load[$hOption.sType;$sFileSpec;$hOption]]
	}
	^case[sql;force]{
		^self._execute{$jQuery}
	}
	^case[skip-save]{
		^self._delete[$sFileSpec]
		^self._execute{$jQuery}
	}
	^case[DEFAULT]{
		^self._delete[$sFileSpec]
		^self._execute{$jQuery}
		^self._save[$hOption.sType;$sFileSpec;$caller.result]
	}
}
$result[]


@_getFileSpec[hOptions][result]
^if(def $hOptions.hCache.sFile){
	$result[$self.sCacheDir/$hOptions.hCache.sFile]
}(^hOptions.hCache.bAuto.bool($self.bCacheAuto)){
	$result[$self.sCacheDir/$self.sCacheAutoSubDir/^math:md5[$hOptions.sQuery]^if(def $hOptions.hSql && ($hOptions.hSql.limit || $hOptions.hSql.offset)){=$hOptions.hSql.limit=$hOptions.hSql.offset}.$hOptions.sType]
}{
	$result[]
}



@_save[sType;sFileSpec;uValue][tKey;t;c;sKey;sValue]
^switch[$sType]{
	^case[int;double;string]{
		^uValue.save[$sFileSpec]
	}
	^case[table]{
		^uValue.save[$sFileSpec;$.encloser["]]
	}
	^case[hash]{
		$tKey[^uValue._keys[]]
		^if($uValue.[$tKey.key] is "hash"){
			$t[^table::create{key^uValue.[$tKey.key].foreach[sKey;]{^#09$sKey}}]
			^tKey.menu{^t.append{$tKey.key^uValue.[$tKey.key].foreach[;sValue]{^#09$sValue}}}
		}($uValue.[$tKey.key] is "string"){
			$t[^table::create{key^#09value}]
			^tKey.menu{^t.append{${tKey.key}^#09$uValue.[$tKey.key]}}
		}($uValue.[$tKey.key] is "table"){
			$c[^uValue.[$tKey.key].columns[]]
			$t[^table::create{^c.menu{$c.column}[^#09]}]
			^tKey.menu{^t.join[$uValue.[$tKey.key]]}
		}{
			$t[^table::create{key}]
			^tKey.menu{^t.append{$tKey.key}}
		}
		^self._save[table;$sFileSpec;$t]
	}
	^case[file]{
		^uValue.save[binary;$sFileSpec]
	}
	^case[void]{}
}
$result[]



@_load[sType;sFileSpec;hOption][f;t;c]
^switch[$sType]{
	^case[int]{
		$f[^file::load[text;$sFileSpec]]
		$result(^f.text.int(0))
	}
	^case[double]{
		$f[^file::load[text;$sFileSpec]]
		$result(^f.text.double(0))
	}
	^case[string]{
		$f[^file::load[text;$sFileSpec]]
		$result[$f.text]
	}
	^case[table]{
		$result[^table::load[$sFileSpec;$.encloser["]]]
	}
	^case[hash]{
		$t[^self._load[table;$sFileSpec]]
		$c[^t.columns[]]
		^switch[$hOption.hSql.type]{
			^case[string]{$result[^t.hash[$c.column][value][$.type[$hOption.hSql.type]]]}
			^case[table]{$result[^t.hash[$c.column][$.type[$hOption.hSql.type]]]}
			^case[DEFAULT]{$result[^t.hash[$c.column]]]}
		}
	}
	^case[file]{
		$result[^file::load[binary;$sFileSpec]]
	}
	^case[void]{
		$result[]
	}
}