appkit  1.5.1
RoadNarrows Robotics Application Kit
IOManip.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: RoadNarrows Robotics Application Tool Kit
4 //
5 // Link: https://github.com/roadnarrows-robotics/rnr-sdk
6 //
7 // Library: librnr_appkit
8 //
9 // File: IOManip.h
10 //
11 /*! \file
12  *
13  * \brief Stream I/O manipulators and helpers.
14  *
15  * \author Robin Knight (robin.knight@roadnarrows.com)
16  *
17  * \par Copyright
18  * \h_copy 2016-2017. RoadNarrows LLC.\n
19  * http://www.roadnarrows.com\n
20  * All Rights Reserved
21  *
22  * \par License:
23  * MIT
24  */
25 /*
26  * @EulaBegin@
27  *
28  * Permission is hereby granted, without written agreement and without
29  * license or royalty fees, to use, copy, modify, and distribute this
30  * software and its documentation for any purpose, provided that
31  * (1) The above copyright notice and the following two paragraphs
32  * appear in all copies of the source code and (2) redistributions
33  * including binaries reproduces these notices in the supporting
34  * documentation. Substantial modifications to this software may be
35  * copyrighted by their authors and need not follow the licensing terms
36  * described here, provided that the new terms are clearly indicated in
37  * all files where they apply.
38  *
39  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
40  * OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
41  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
42  * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
43  * EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
44  * THE POSSIBILITY OF SUCH DAMAGE.
45  *
46  * THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
47  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
48  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
49  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
50  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
51  *
52  * @EulaEnd@
53  */
54 ////////////////////////////////////////////////////////////////////////////////
55 
56 #ifndef _RNR_IO_MANIP_H
57 #define _RNR_IO_MANIP_H
58 
59 #include <stdio.h>
60 #include <unistd.h>
61 #include <stdlib.h>
62 #include <ctype.h>
63 
64 #include <iostream>
65 #include <iomanip>
66 #include <sstream>
67 #include <string>
68 
69 /*!
70  * \brief RoadNarrows Robotics
71  */
72 namespace rnr
73 {
74  /*!
75  * \brief Input/Output
76  */
77  namespace io
78  {
79  /*!
80  * \brief Output stream indentation manipulator structure.
81  */
83  {
84  /*
85  * \brief Indentation change type enum.
86  */
87  enum change
88  {
89  NoChange, ///< no change
90  Relative, ///< relative to current indentation level (delta)
91  Absolute ///< absolute
92  };
93 
94  long m_nIndent; ///< new indentation value
95  change m_eChange; ///< how the new indentationn is to be applied
96  bool m_bOut; ///< do [not] output indentaion
97  };
98 
99  /*!
100  * \brief Set absolute indentation level.
101  *
102  * \param nIndent Number of spaces to left indent.
103  *
104  * \return Indent manipulation object.
105  */
106  osManipIndent setindent(const long nIndent);
107 
108  /*!
109  * \brief Set relative delta indentation level.
110  *
111  * \param nDelta Plus or minus delta from current indentation level.
112  *
113  * \return Indent manipulation object.
114  */
115  osManipIndent deltaindent(const long nDelta);
116 
117  /*!
118  * \brief Left indent at current stream indentation level.
119  *
120  * \return Indent manipulation object.
121  */
123 
124  /*!
125  * \brief Insert indentation object into output stream.
126  *
127  * \param os Output stream.
128  * \param f Object to insert.
129  *
130  * \return Reference to output stream.
131  */
132  std::ostream &operator<<(std::ostream &os, const osManipIndent &f);
133 
134  } // namespace io
135 } // namespace rnr
136 
137 #endif // _RNR_IO_MANIP_H
bool m_bOut
do [not] output indentaion
Definition: IOManip.h:96
osManipIndent indent()
Left indent at current stream indentation level.
Definition: IOManip.cxx:115
change m_eChange
how the new indentationn is to be applied
Definition: IOManip.h:95
relative to current indentation level (delta)
Definition: IOManip.h:90
osManipIndent setindent(const long nIndent)
Set absolute indentation level.
Definition: IOManip.cxx:81
long m_nIndent
new indentation value
Definition: IOManip.h:94
Output stream indentation manipulator structure.
Definition: IOManip.h:82
std::ostream & operator<<(std::ostream &os, const osManipIndent &f)
Insert indentation object into output stream.
osManipIndent deltaindent(const long nDelta)
Set relative delta indentation level.
Definition: IOManip.cxx:99
RoadNarrows Robotics.
Definition: Camera.h:74