nis-util  1.0.D108
lib/space/auto_master.cc
Go to the documentation of this file.
00001 //
00002 // nis-util - NIS Administration Utilities
00003 // Copyright (C) 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 along
00016 // with this program. If not, see <http://www.gnu.org/licenses/>.
00017 //
00018 
00019 #include <lib/output/file.h>
00020 #include <lib/space/auto_master.h>
00021 #include <lib/space/auto_master/functor.h>
00022 
00023 
00024 space_auto_master::~space_auto_master()
00025 {
00026 }
00027 
00028 
00029 space_auto_master::space_auto_master(const rcstring &a_filename) :
00030     space(a_filename)
00031 {
00032     discard_blank_lines();
00033     discard_comments();
00034     discard_backslash_newline();
00035 }
00036 
00037 
00038 space_auto_master::pointer
00039 space_auto_master::create(const rcstring &a_filename)
00040 {
00041     return pointer(new space_auto_master(a_filename));
00042 }
00043 
00044 
00045 void
00046 space_auto_master::print(void)
00047     const
00048 {
00049     print(get_file_name());
00050 }
00051 
00052 
00053 void
00054 space_auto_master::print(const rcstring &a_filename)
00055     const
00056 {
00057     output::pointer op = output_file::create(a_filename);
00058     for
00059     (
00060         content_t::const_iterator it = content.begin();
00061         it != content.end();
00062         ++it
00063     )
00064     {
00065         space_auto_master_row::pointer rp = *it;
00066         rp->print(op);
00067     }
00068 }
00069 
00070 
00071 void
00072 space_auto_master::insert(const space_auto_master_row::pointer &rp)
00073 {
00074     content.push_back(rp);
00075 }
00076 
00077 
00078 void
00079 space_auto_master::walk(space_auto_master_functor &func)
00080 {
00081     for
00082     (
00083         content_t::const_iterator it = content.begin();
00084         it != content.end();
00085         ++it
00086     )
00087     {
00088         space_auto_master_row::pointer rp = *it;
00089         func(rp);
00090     }
00091 }
00092 
00093 
00094 // vim: set ts=8 sw=4 et :