pike.git / lib / modules / __builtin.pmod / Range.pike

version» Context lines:

pike.git/lib/modules/__builtin.pmod/Range.pike:1:   #pike __REAL_VERSION__   #pragma strict_types    - //! Generic lightweight range type. + //! Generic lightweight range type. Supports any values for lower + //! and upper boundaries that implement the @expr{`<@} lfun.   //! @note   //! Can only contain a single contiguous range.    - //! + //! The lower inclusive boundary.   mixed from;    - //! + //! The upper exclusive boundary.   mixed till;      //! @param from - //! Lower inclusive limit for the interval. Specify no lower-limit + //! Lower inclusive boundary for the range. Specify no lower-boundary   //! by filling in @expr{-Math.inf@}.   //! @param till - //! Upper exclusive limit for the interval. Specify no upper-limit + //! Upper exclusive boundary for the range. Specify no upper-boundary   //! by filling in @expr{Math.inf@}.   //! @seealso   //! [Math.inf]   protected variant void create(mixed from, mixed till) {    this::from = from;    this::till = till;   }   protected variant void create(object/*this_program*/ copy) {    from = copy->from;    till = copy->till;
pike.git/lib/modules/__builtin.pmod/Range.pike:72:   protected int(0..1) `<(mixed that) {    return from < ([object]that)->from    || from == ([object]that)->from && till < ([object]that)->till;   }      protected int(0..1) `==(mixed that) {    return objectp(that)    && from == ([object]that)->from && till == ([object]that)->till;   }    - //! + //! Casting a range to string delivers an SQL-compliant value.   protected mixed cast(string to) {    if (to == "string")    return from >= till ? "empty" : sprintf("%c%s,%s)",    from == -Math.inf ? '(' : '[', from == -Math.inf ? "" : (string)from,    till == Math.inf ? "" : (string)till);    return UNDEFINED;   }      protected string _sprintf(int fmt, mapping(string:mixed) params) {    switch (fmt) {    case 'O': return sprintf("this_program( %s )", (string)this);    case 's': return (string)this;    }    return sprintf(sprintf("%%*%c", fmt), params, 0);   }