Class ::xo::OrderedComposite::IndexCompare (public)
::xotcl::Class ::xo::OrderedComposite::IndexCompare
- Testcases:
- No testcase defined.
Source code: ::nsf::object::alloc ::xotcl::Class ::xo::OrderedComposite::IndexCompare {set :__default_metaclass ::xotcl::Class set :__default_superclass ::xotcl::Object} ::xo::OrderedComposite::IndexCompare instproc __compare {a b} { set by ${:__orderby} set x [$a set $by] set y [$b set $by] #:log "--value compare $x $y] => [:__value_compare $x $y 0]" return [:__value_compare $x $y 0] } ::xo::OrderedComposite::IndexCompare instproc __value_compare {x y def} { set xp [string first . $x] set yp [string first . $y] if {$xp == -1 && $yp == -1} { if {$x < $y} { return -1 } elseif {$x > $y} { return 1 } else { return $def } } elseif {$xp == -1} { set yh [string range $y 0 $yp-1] return [:__value_compare $x $yh -1] } elseif {$yp == -1} { set xh [string range $x 0 $xp-1] return [:__value_compare $xh $y 1] } else { set xh [string range $x 0 $xp] set yh [string range $y 0 $yp] #:log "xh=$xh yh=$yh" if {$xh < $yh} { return -1 } elseif {$xh > $yh} { return 1 } else { incr xp incr yp #:log "rest [string range $x $xp end] [string range $y $yp end]" return [:__value_compare [string range $x $xp end] [string range $y $yp end] $def] } } }XQL Not present: Generic, PostgreSQL, Oracle