nis-util  1.0.D108
lib/space/automap/row/compound.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/space/automap/row/compound.h>
00020 #include <lib/output/prefix.h>
00021 #include <lib/output/string.h>
00022 #include <lib/space/automap.h>
00023 
00024 
00025 space_automap_row_compound::~space_automap_row_compound()
00026 {
00027 }
00028 
00029 
00030 space_automap_row_compound::space_automap_row_compound(
00031     const mount_point &a_key,
00032     const rcstring &a_options,
00033     const parts_t &a_parts
00034 ) :
00035     space_automap_row(a_key, a_options),
00036     parts(a_parts)
00037 {
00038 }
00039 
00040 
00041 space_automap_row_compound::pointer
00042 space_automap_row_compound::create(const mount_point &a_key,
00043     const rcstring &a_options, const parts_t &a_parts)
00044 {
00045     return pointer(new space_automap_row_compound(a_key, a_options, a_parts));
00046 }
00047 
00048 
00049 void
00050 space_automap_row_compound::print(const output_pointer &op)
00051     const
00052 {
00053     op->put(get_mount_point().get_mount_point());
00054     if (!get_options().empty())
00055     {
00056         op->indent_to(8);
00057         op->put(get_options());
00058     }
00059 
00060     for
00061     (
00062         parts_t::const_iterator it = parts.begin();
00063         it != parts.end();
00064         ++it
00065     )
00066     {
00067         space_automap_row::pointer rp = *it;
00068         output_string::pointer op2 =
00069             output_string::create(op->get_line_width() - 10);
00070         output::pointer op3 = output_prefix::create(op2, 8);
00071         rp->print(op3);
00072         rcstring text = op2->mkstr();
00073         text = text.trim_right();
00074 
00075         op->put(" \\\n");
00076         op->put(text);
00077     }
00078     op->put('\n');
00079 }
00080 
00081 
00082 void
00083 space_automap_row_compound::space_automap_insert_sub(space_automap *sap)
00084     const
00085 {
00086     for (parts_t::const_iterator it = parts.begin(); it != parts.end(); ++it)
00087     {
00088         space_automap_row::pointer rp = *it;
00089         rp = rp->repath(get_mount_point());
00090         sap->insert_sub(rp);
00091         rp->space_automap_insert_sub(sap);
00092     }
00093 }
00094 
00095 
00096 space_automap_row::pointer
00097 space_automap_row_compound::repath(const mount_point &stem)
00098     const
00099 {
00100     return create(stem + get_mount_point(), get_options(), parts);
00101 }
00102 
00103 
00104 // vim: set ts=8 sw=4 et :