author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Sun, 02 Mar 2008 21:00:37 +0100 | |
changeset 2531 | b451b5fc8b57 |
parent 1703 | 3f808ee49c2f |
child 2575 | 1aae382e65e2 |
permissions | -rw-r--r-- |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
599
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
2 |
/* |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
3 |
* Copyright (c) 2007 Georgia Tech University, INRIA |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
4 |
* |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
7 |
* published by the Free Software Foundation; |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
8 |
* |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
12 |
* GNU General Public License for more details. |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
13 |
* |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
17 |
* |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
18 |
* Authors: Raj Bhattacharjea <raj.b@gatech.edu>, |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
19 |
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
7b7012218291
add license header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
538
diff
changeset
|
20 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
21 |
#ifndef COMMAND_LINE_H |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
22 |
#define COMMAND_LINE_H |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
23 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
24 |
#include <list> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
25 |
#include <string> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
26 |
#include "default-value.h" |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
27 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
28 |
namespace ns3 { |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
29 |
|
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
30 |
/** |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
31 |
* \brief Command line argument processing class |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
32 |
* \ingroup config |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
33 |
* |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
34 |
* Often times in simulations, the user will want the ability to change and |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
35 |
* tweak simulation parameters without having to recompile the entire |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
36 |
* simulation. This can be done by passing arguments in from the command |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
37 |
* line invocation of a simulation. |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
38 |
* This class is a collection of static functions to aid in this facility. |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
39 |
* By using it, users get the automatic things like support for --help command |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
40 |
* line arguments. See samples/main-default-value.cc for more info. |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
41 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
42 |
class CommandLine |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
43 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
44 |
public: |
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
45 |
/** |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
46 |
* \brief Add a command line argument to the system |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
47 |
* \param name Name of the string to expect on the command line |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
48 |
* \param help A help string for this param, displayed --help is used. |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
49 |
* \param value The desination to store the value read from the command line |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
50 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
51 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
52 |
static void AddArgValue (const std::string &name, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
53 |
const std::string &help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
54 |
T &value); |
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
55 |
/** |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
56 |
* \brief Add a command line triggered function call to the system |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
57 |
* \param name Name of the string to expect on the command line |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
58 |
* \param help A help string for this param, displayed --help is used. |
630
2f285162b6ca
fix dox warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
599
diff
changeset
|
59 |
* \param cb An ns3::Callback that gets called if name is present as a |
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
60 |
* commandline argument. |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
61 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
62 |
static void AddArgCommand (const std::string &name, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
63 |
const std::string &help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
64 |
Callback<void> cb); |
538
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
65 |
/** |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
66 |
* \brief Parse the command line for arguments thus far added |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
67 |
* \param argc Number of strings on the command line; pass this directly from |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
68 |
* the first argument of your main(int,char**) function |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
69 |
* \param argv Array of strings passed in as arguments; pass this directly from |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
70 |
* the second argument of your main(int,char**) function |
3cc417842b5f
Added/fixed some doxygen
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
441
diff
changeset
|
71 |
*/ |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
72 |
static void Parse (int argc, char *argv[]); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
73 |
private: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
74 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
75 |
class UserDefaultValue : public DefaultValueBase |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
76 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
77 |
public: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
78 |
UserDefaultValue (const std::string &name, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
79 |
const std::string &help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
80 |
T &value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
81 |
private: |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
82 |
virtual bool DoParseValue (const std::string &value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
83 |
virtual std::string DoGetType (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
84 |
virtual std::string DoGetDefaultValue (void) const; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
85 |
T *m_valuePtr; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
86 |
}; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
87 |
static void PrintHelp (void); |
1703
3f808ee49c2f
Fix CommandLine::AddArgCommand memory leak.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1702
diff
changeset
|
88 |
|
3f808ee49c2f
Fix CommandLine::AddArgCommand memory leak.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1702
diff
changeset
|
89 |
class List : public std::list<DefaultValueBase *> |
3f808ee49c2f
Fix CommandLine::AddArgCommand memory leak.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1702
diff
changeset
|
90 |
{ |
3f808ee49c2f
Fix CommandLine::AddArgCommand memory leak.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1702
diff
changeset
|
91 |
public: |
3f808ee49c2f
Fix CommandLine::AddArgCommand memory leak.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1702
diff
changeset
|
92 |
~List (); |
3f808ee49c2f
Fix CommandLine::AddArgCommand memory leak.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1702
diff
changeset
|
93 |
}; |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
94 |
static List *GetUserList (void); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
95 |
static CommandDefaultValue g_help; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
96 |
}; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
97 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
98 |
}//namespace ns3 |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
99 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
100 |
namespace ns3 { |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
101 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
102 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
103 |
void |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
104 |
CommandLine::AddArgValue (const std::string &name, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
105 |
const std::string &help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
106 |
T &value) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
107 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
108 |
DefaultValueBase *base = |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
109 |
new UserDefaultValue<T> (name, help, value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
110 |
GetUserList ()->push_back (base); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
111 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
112 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
113 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
114 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
115 |
CommandLine::UserDefaultValue<T>::UserDefaultValue (const std::string &name, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
116 |
const std::string &help, |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
117 |
T &value) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
118 |
: DefaultValueBase (name, help), |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
119 |
m_valuePtr (&value) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
120 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
121 |
// we do not register in the DefaultValueList class on purpose. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
122 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
123 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
124 |
bool |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
125 |
CommandLine::UserDefaultValue<T>::DoParseValue (const std::string &value) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
126 |
{ |
441
d824620eac38
Added default value sample
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
439
diff
changeset
|
127 |
std::istringstream iss; |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
128 |
iss.str (value); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
129 |
T v; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
130 |
iss >> v; |
1702
0fbe74581141
Bug 81 (CommandLine::AddArgValue not working correctly)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
630
diff
changeset
|
131 |
bool ok = (!iss.bad () && !iss.fail ()); |
0fbe74581141
Bug 81 (CommandLine::AddArgValue not working correctly)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
630
diff
changeset
|
132 |
if (ok) |
0fbe74581141
Bug 81 (CommandLine::AddArgValue not working correctly)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
630
diff
changeset
|
133 |
{ |
0fbe74581141
Bug 81 (CommandLine::AddArgValue not working correctly)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
630
diff
changeset
|
134 |
*m_valuePtr = v; |
0fbe74581141
Bug 81 (CommandLine::AddArgValue not working correctly)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
630
diff
changeset
|
135 |
} |
0fbe74581141
Bug 81 (CommandLine::AddArgValue not working correctly)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
630
diff
changeset
|
136 |
return ok; |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
137 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
138 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
139 |
std::string |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
140 |
CommandLine::UserDefaultValue<T>::DoGetType (void) const |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
141 |
{ |
1702
0fbe74581141
Bug 81 (CommandLine::AddArgValue not working correctly)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
630
diff
changeset
|
142 |
return TypeNameGet<T> (); |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
143 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
144 |
template <typename T> |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
145 |
std::string |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
146 |
CommandLine::UserDefaultValue<T>::DoGetDefaultValue (void) const |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
147 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
148 |
return ""; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
149 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
150 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
151 |
}//namespace ns3 |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
152 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
153 |
#endif /* COMMAND_LINE_H */ |