The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
parcel KinoSearch cnick Kino;

/** Element of a SortSpec.
 *
 * SortRules are the building blocks used to assemble
 * L<SortSpecs|KinoSearch::Search::SortSpec>; each SortRule defines a single
 * level of sorting.  For example, sorting first by "category" then by score
 * requires a SortSpec with two SortRule elements.
 */
class KinoSearch::Search::SortRule inherits KinoSearch::Object::Obj {

    int32_t   type;
    CharBuf  *field;
    bool_t    reverse;

    inert int32_t FIELD;
    inert int32_t SCORE;
    inert int32_t DOC_ID;

    public inert incremented SortRule*
    new(int32_t type = 0, const CharBuf *field = NULL, 
        bool_t reverse = false);

    /**
     * @param type Indicate whether to sort by score, field, etc.  (The
     * default is to sort by a field.)
     * @param field The name of a <code>sortable</code> field.
     * @param reverse If true, reverse the order of the sort for this rule.
     */
    public inert incremented SortRule*
    init(SortRule *self, int32_t type = 0, const CharBuf *field = NULL, 
         bool_t reverse = false);

    /** Accessor for "field" member. 
     */
    public nullable CharBuf*
    Get_Field(SortRule *self);

    /** Accessor for "type" member. 
     */
    public int32_t
    Get_Type(SortRule *self);

    /** Accessor for "reverse" member. 
     */
    public bool_t
    Get_Reverse(SortRule *self);

    public incremented SortRule*
    Deserialize(SortRule *self, InStream *instream);

    public void
    Serialize(SortRule *self, OutStream *outstream);

    public void
    Destroy(SortRule *self);
}

/* Copyright 2007-2011 Marvin Humphrey
 *
 * This program is free software; you can redistribute it and/or modify
 * under the same terms as Perl itself.
 */