1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2008 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #include "OSGIOFileTypeBase.h"
43 /*-------------------------------------------------------------------------*/
44 /* IOFileTypeBase::IOOption */
45 /*-------------------------------------------------------------------------*/
47 IOFileTypeBase::IOOption::IOOption(void)
55 IOFileTypeBase::IOOption::IOOption(IOOption
const &other
)
57 : optName (other
.optName
),
58 optValue(other
.optValue
)
63 IOFileTypeBase::IOOption::IOOption(
64 const std::string
&name
, const std::string
&value
)
72 /*-------------------------------------------------------------------------*/
74 /*-------------------------------------------------------------------------*/
76 /*-------------------------------------------------------------------------*/
80 IOFileTypeBase::getFlags(void) const
85 /*-------------------------------------------------------------------------*/
88 /*! Pushes the current options onto the option stack. If \c copyTop is \c true
89 a copy of the current options is used as the new current options, otherwise
90 an empty options set is used.
92 \param[in] copyTop Whether to copy the current options.
95 IOFileTypeBase::pushOptions(bool copyTop
)
99 _optStack
.push(_optStack
.top());
103 _optStack
.push(OptionSet());
107 /*! Pops the next option set from the stack and makes it the current options.
110 IOFileTypeBase::popOptions(void)
112 if(_optStack
.size() > 1)
118 FWARNING(("IOFileTypeBase::popOptions: Can not remove last element "
119 "from options stack.\n"));
123 /*! Sets the option \a name to \a value in \a optSet overwriting
126 \param[in] optSet OptionSet to modify.
127 \param[in] name Name of the option.
128 \param[in] value Value of the option.
131 IOFileTypeBase::setOption(
132 OptionSet
&optSet
, const std::string
&name
, const std::string
&value
)
134 optSet
[name
] = IOOption(name
, value
);
137 /*! Removes the option \a name from \a optSet. If the option is not present
138 \c false is returned, \c true otherwise.
140 \param[in] optSet OptionSet to modify.
141 \param[in] name Name of the option.
142 \return Whether the option was successfully removed.
145 IOFileTypeBase::unsetOption(OptionSet
&optSet
, const std::string
&name
)
148 OptionSet::iterator oIt
= optSet
.find(name
);
150 if(oIt
!= optSet
.end())
159 /*! Attempts to return the \a value associated with option \a name
160 in \a optSet. If the option is not present \c false is returned,
161 \c true otherwise and only in this case value is being set.
163 \param[in] optSet OptionSet to read.
164 \param[in] name Name of the option.
165 \param[out] value Value of option.
166 \return Whether the option is present.
169 IOFileTypeBase::getOption(
170 const OptionSet
&optSet
, std::string
const &name
, std::string
&value
)
173 OptionSet::const_iterator oIt
= optSet
.find(name
);
175 if(oIt
!= optSet
.end())
177 value
= oIt
->second
.optValue
;
184 /*-------------------------------------------------------------------------*/
188 IOFileTypeBase::IOFileTypeBase(UInt32
const flags
)
193 _optStack
.push(OptionSet());
196 IOFileTypeBase::IOFileTypeBase(Self
const &other
)
198 : _flags (other
._flags
),
199 _optStack(other
._optStack
)
203 /*-------------------------------------------------------------------------*/
206 IOFileTypeBase::~IOFileTypeBase(void)