/*
 * Copyright (c) 1999 Johnny C. Lam.
 * All rights reserved.
 *
 * Permission to use, copy, modify, distribute and sell this software
 * and its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.  The author makes no representations
 * about the suitability of this software for any purpose.  It is
 * provided "as is" without express or implied warranty.
 */

// -*- C++ -*-

inline
Marker::Marker(int i)
    : _marker((i < 0) ? NA : i)
{}

inline    
bool
Marker::IsNA() const
{
    return _marker < 0;
}

inline
int
Marker::Value() const
{
    return _marker;
}

/*
 * NA == any marker value, including NA.
 */
inline
bool
operator==(Marker lhs, Marker rhs)
{
    return lhs.IsNA() || rhs.IsNA() || lhs.Value() == rhs.Value();
}

/*
 * NA < any positive marker value.
 * NA satisfies (not(NA < NA) and not(NA > NA)), hence by this criterion,
 * NA == NA for sorting purposes.
 */
inline
bool
operator<(Marker lhs, Marker rhs)
{
    return lhs.Value() < rhs.Value();
}

inline
istream&
operator>>(istream& istr, Marker &m)
{
    m.Read(istr);
    return istr;
}
