xorp

xrl_atom_list.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 // vim:set sts=4 ts=8:
00003 
00004 // Copyright (c) 2001-2011 XORP, Inc and Others
00005 //
00006 // This program is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU Lesser General Public License, Version
00008 // 2.1, June 1999 as published by the Free Software Foundation.
00009 // Redistribution and/or modification of this program under the terms of
00010 // any other version of the GNU Lesser General Public License is not
00011 // permitted.
00012 // 
00013 // This program is distributed in the hope that it will be useful, but
00014 // WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
00016 // see the GNU Lesser General Public License, Version 2.1, a copy of
00017 // which can be found in the XORP LICENSE.lgpl file.
00018 // 
00019 // XORP, Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
00020 // http://xorp.net
00021 
00022 // $XORP: xorp/libxipc/xrl_atom_list.hh,v 1.16 2008/10/02 21:57:24 bms Exp $
00023 
00024 #ifndef __LIBXIPC_XRL_ATOM_LIST_HH__
00025 #define __LIBXIPC_XRL_ATOM_LIST_HH__
00026 
00027 
00028 #include "libxorp/exceptions.hh"
00029 
00030 class XrlAtom;
00031 
00040 class XrlAtomList {
00041 public:
00042     struct BadAtomType : public XorpReasonedException {
00043     BadAtomType(const char* file, size_t line, const string& init_why)
00044         : XorpReasonedException("BadAtomType", file, line, init_why)
00045     {}
00046     };
00047     struct InvalidIndex : public XorpReasonedException {
00048     InvalidIndex(const char* file, size_t line, const string& init_why)
00049         : XorpReasonedException("InvalidIndex", file, line, init_why)
00050     {}
00051     };
00052 
00053 public:
00054     XrlAtomList();
00055 
00061     void prepend(const XrlAtom& xa) throw (BadAtomType);
00062 
00068     void append(const XrlAtom& xa) throw (BadAtomType);
00069 
00076     const XrlAtom& get(size_t itemno) const throw (InvalidIndex);
00077 
00083     void remove(size_t itemno) throw (InvalidIndex);
00084 
00088     size_t size() const;
00089 
00095     bool operator==(const XrlAtomList& x) const;
00096 
00101     string str() const;
00102 
00106     XrlAtomList(const string& s);
00107 
00108     size_t  modify(size_t item, const uint8_t* buf, size_t len);
00109     void    set_size(size_t size);
00110 
00111 private:
00112     void    check_type(const XrlAtom& xa) throw (BadAtomType);
00113     void    do_append(const XrlAtom& xa);
00114 
00115     list<XrlAtom> _list;
00116     size_t    _size;
00117 };
00118 
00119 #endif // __LIBXIPC_XRL_ATOM_LIST_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations