/usr/include/IceUtil/Options.h is in libzeroc-ice35-dev 3.5.1-5.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | // **********************************************************************
//
// Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#ifndef ICE_UTIL_OPTIONS_H
#define ICE_UTIL_OPTIONS_H
#include <IceUtil/Config.h>
#include <IceUtil/RecMutex.h>
#include <IceUtil/Shared.h>
#include <IceUtil/Handle.h>
#include <IceUtil/Exception.h>
#include <string>
#include <vector>
#include <map>
namespace IceUtilInternal
{
class ICE_UTIL_API APIException : public IceUtil::Exception
{
public:
APIException(const char*, int, const ::std::string&);
virtual ~APIException() throw();
virtual ::std::string ice_name() const;
virtual void ice_print(std::ostream&) const;
virtual APIException* ice_clone() const;
virtual void ice_throw() const;
::std::string reason;
private:
static const char* _name;
};
ICE_UTIL_API ::std::ostream& operator<<(::std::ostream&, const APIException&);
class ICE_UTIL_API BadOptException : public IceUtil::Exception
{
public:
BadOptException(const char*, int, const ::std::string&);
virtual ~BadOptException() throw();
virtual ::std::string ice_name() const;
virtual void ice_print(std::ostream&) const;
virtual BadOptException* ice_clone() const;
virtual void ice_throw() const;
::std::string reason;
private:
static const char* _name;
};
ICE_UTIL_API ::std::ostream& operator<<(::std::ostream&, const BadOptException&);
class ICE_UTIL_API Options
{
public:
enum LengthType { ShortOpt, LongOpt };
enum RepeatType { Repeat, NoRepeat };
enum ArgType { NeedArg, NoArg };
Options();
void addOpt(const ::std::string&, const ::std::string& = "",
ArgType = NoArg, ::std::string = "", RepeatType = NoRepeat);
typedef ::std::vector< ::std::string> StringVector;
static StringVector split(const ::std::string&);
StringVector parse(const StringVector&);
StringVector parse(int, const char* const []);
bool isSet(const ::std::string&) const;
::std::string optArg(const ::std::string&) const;
StringVector argVec(const ::std::string&) const;
private:
struct OptionDetails : public IceUtil::Shared
{
LengthType length;
ArgType arg;
RepeatType repeat;
bool hasDefault;
};
typedef IceUtil::Handle<OptionDetails> ODPtr;
struct OptionValue : public IceUtil::Shared
{
::std::string val;
};
typedef IceUtil::Handle<OptionValue> OValPtr;
struct OptionValueVector : public IceUtil::Shared
{
::std::vector< ::std::string> vals;
};
typedef IceUtil::Handle<OptionValueVector> OVecPtr;
typedef ::std::map< ::std::string, ODPtr> ValidOpts; // Valid options and their details.
typedef ::std::map< ::std::string, OValPtr> Opts; // Value of non-repeating options.
typedef ::std::map< ::std::string, OVecPtr> ROpts; // Value of repeating options.
typedef ::std::map< ::std::string, ::std::string> Synonyms; // Map from short to long option and vice versa.
void addValidOpt(const ::std::string&, const ::std::string&, ArgType, const ::std::string&, RepeatType);
ValidOpts::iterator checkOpt(const ::std::string&, LengthType);
void setOpt(const ::std::string&, const ::std::string&, const ::std::string&, RepeatType);
void setNonRepeatingOpt(const ::std::string&, const ::std::string&);
void setRepeatingOpt(const ::std::string&, const ::std::string&);
ValidOpts::const_iterator checkOptIsValid(const ::std::string&) const;
ValidOpts::const_iterator checkOptHasArg(const ::std::string&) const;
void updateSynonyms(const ::std::string&, const ::std::string&);
::std::string getSynonym(const ::std::string&) const;
ValidOpts _validOpts;
Opts _opts;
ROpts _ropts;
Synonyms _synonyms;
bool parseCalled;
IceUtil::RecMutex _m;
Options(const Options&); // Not allowed.
void operator=(const Options&); // Not allowed.
static void checkArgs(const ::std::string&, const ::std::string&, bool, const ::std::string&);
};
}
#endif
|