nis-util  1.0.D108
lib/space/protocols.h
Go to the documentation of this file.
00001 //
00002 // nis-util - NIS Administration Utilities
00003 // Copyright (C) 2002, 2008, 2009, 2012 Peter Miller
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or (at
00008 // your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program. If not, see <http://www.gnu.org/licenses/>.
00017 //
00018 
00019 #ifndef LIB_SPACE_PROTOCOLS_H
00020 #define LIB_SPACE_PROTOCOLS_H
00021 
00022 #include <list>
00023 #include <boost/shared_ptr.hpp>
00024 
00025 #include <lib/space.h>
00026 
00031 class space_protocols:
00032     public space
00033 {
00034 public:
00035     typedef boost::shared_ptr<space_protocols> pointer;
00036 
00040     virtual ~space_protocols();
00041 
00049     static pointer create(const rcstring &filename);
00050 
00055     class record
00056     {
00057     public:
00058         typedef boost::shared_ptr<record> pointer;
00059 
00060         ~record();
00061 
00062         typedef std::list<rcstring> aliases_t;
00063 
00077         static pointer create(const source_location &locn, const rcstring &name,
00078             const rcstring &number, const aliases_t &aliases);
00079 
00086         rcstring representation(void) const;
00087 
00088         const source_location &get_source_location(void) const { return locn; }
00089         rcstring get_name(void) const { return name; }
00090         rcstring get_number(void) const { return number; }
00091         int get_number_binary(void) const;
00092         const aliases_t &get_aliases(void) const { return aliases; }
00093 
00094     private:
00108         record(const source_location &locn, const rcstring &name,
00109             const rcstring &number, const aliases_t &aliases);
00110 
00115         source_location locn;
00116 
00121         rcstring name;
00122 
00127         rcstring number;
00128 
00133         aliases_t aliases;
00134 
00138         record();
00139 
00143         record(const record &rhs);
00144 
00148         record &operator=(const record &rhs);
00149     };
00150 
00162     record::pointer get(void);
00163 
00181     static bool is_ok_name(const rcstring &text, bool upper_case_ok,
00182         rcstring &suggestion);
00183 
00184 protected:
00192     space_protocols(const rcstring &filename);
00193 
00194 private:
00199     int last_num;
00200 
00204     space_protocols();
00205 
00209     space_protocols(const space_protocols &);
00210 
00214     space_protocols &operator=(const space_protocols &);
00215 };
00216 
00217 // vim: set ts=8 sw=4 et :
00218 #endif // LIB_SPACE_PROTOCOLS_H