/** \file
 *
 *  Contains the CodedStr class declaration.
 *
 *  Copyright (c) 2007,2008,2009 MBARI
 *  MBARI Proprietary Information.  All Rights Reserved
 */

#ifndef CODEDSTR_H_
#define CODEDSTR_H_

#include "Str.h"
#include "io/InStream.h"
#include "io/OutStream.h"

/**
 *  Extends the Str class, adding an unsigned short code
 *  (actually, the codes are limited to 14 bits, for
 *  a range of 0 to 16383)
 *
 *  \ingroup utils
 */
class CodedStr : public Str
{
public:
    CodedStr( const Str& strIn, unsigned short code = NO_CODE );

    virtual ~CodedStr()
    {}

    unsigned short getCode() const
    {
        return code_;
    }

    void setCode( const unsigned short code )
    {
        code_ = code;
    }

    unsigned int write( OutStream& outStream ) const;

    static CodedStr* Read( InStream& inStream );

    static const unsigned short NO_CODE = 0x3FFF;

private:

    unsigned short code_;

};

#endif /*CODEDSTR_H_*/
