author | Mitch Watrous <watrous@u.washington.edu> |
Fri, 14 Dec 2012 14:07:33 -0800 | |
changeset 9193 | 9e679a504fc6 |
parent 9134 | 7a750f032acd |
child 9829 | 0828b3ad8057 |
permissions | -rw-r--r-- |
2581
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
2 |
/* |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
3 |
* Copyright (c) 2008 INRIA |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
4 |
* |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
7 |
* published by the Free Software Foundation; |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
8 |
* |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
12 |
* GNU General Public License for more details. |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
13 |
* |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
17 |
* |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
18 |
* Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
31d4960dc31b
add missing copyright statements.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2575
diff
changeset
|
19 |
*/ |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7393
diff
changeset
|
20 |
|
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7393
diff
changeset
|
21 |
#include <cstdlib> // for exit |
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7393
diff
changeset
|
22 |
|
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
23 |
#include "command-line.h" |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
24 |
#include "log.h" |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
25 |
#include "config.h" |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
26 |
#include "global-value.h" |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
27 |
#include "type-id.h" |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
28 |
#include "string.h" |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7393
diff
changeset
|
29 |
|
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
30 |
|
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
31 |
NS_LOG_COMPONENT_DEFINE ("CommandLine"); |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
32 |
|
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
33 |
namespace ns3 { |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
34 |
|
5844
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
35 |
CommandLine::CommandLine () |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
36 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
37 |
NS_LOG_FUNCTION (this); |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
38 |
} |
5844
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
39 |
CommandLine::CommandLine (const CommandLine &cmd) |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
40 |
{ |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
41 |
Copy (cmd); |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
42 |
} |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
43 |
CommandLine & |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
44 |
CommandLine::operator = (const CommandLine &cmd) |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
45 |
{ |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
46 |
Clear (); |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
47 |
Copy (cmd); |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
48 |
return *this; |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
49 |
} |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
50 |
CommandLine::~CommandLine () |
1703
3f808ee49c2f
Fix CommandLine::AddArgCommand memory leak.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1702
diff
changeset
|
51 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
52 |
NS_LOG_FUNCTION (this); |
5844
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
53 |
Clear (); |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
54 |
} |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
55 |
void |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
56 |
CommandLine::Copy (const CommandLine &cmd) |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
57 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
58 |
NS_LOG_FUNCTION (&cmd); |
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
59 |
|
5844
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
60 |
for (Items::const_iterator i = cmd.m_items.begin (); |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
61 |
i != cmd.m_items.end (); ++i) |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
62 |
{ |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
63 |
m_items.push_back (*i); |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
64 |
} |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
65 |
} |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
66 |
void |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
67 |
CommandLine::Clear (void) |
0dd442f011c7
add copy constructors and assignment operators to avoid leaks.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5255
diff
changeset
|
68 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
69 |
NS_LOG_FUNCTION (this); |
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
70 |
|
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
71 |
for (Items::const_iterator i = m_items.begin (); i != m_items.end (); ++i) |
1703
3f808ee49c2f
Fix CommandLine::AddArgCommand memory leak.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1702
diff
changeset
|
72 |
{ |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
73 |
delete *i; |
1703
3f808ee49c2f
Fix CommandLine::AddArgCommand memory leak.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1702
diff
changeset
|
74 |
} |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
75 |
m_items.clear (); |
1703
3f808ee49c2f
Fix CommandLine::AddArgCommand memory leak.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1702
diff
changeset
|
76 |
} |
3f808ee49c2f
Fix CommandLine::AddArgCommand memory leak.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1702
diff
changeset
|
77 |
|
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
78 |
CommandLine::Item::~Item () |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
79 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
80 |
NS_LOG_FUNCTION (this); |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
81 |
} |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
82 |
|
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
83 |
void |
2915
3573d91994cc
bug 150: CommandLine::Parse argc parameter should not be a reference
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
84 |
CommandLine::Parse (int iargc, char *argv[]) const |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
85 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
86 |
NS_LOG_FUNCTION (this << iargc << argv); |
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
87 |
|
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
88 |
int argc = iargc; |
1533
1e8249c58fda
Fix infinite loop in CommandLine::Parse when trying to ignore a badly formed parameter.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
599
diff
changeset
|
89 |
for (argc--, argv++; argc > 0; argc--, argv++) |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
90 |
{ |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
91 |
// remove "--" or "-" heading. |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
92 |
std::string param = *argv; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
93 |
std::string::size_type cur = param.find ("--"); |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
94 |
if (cur == 0) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
95 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
96 |
param = param.substr (2, param.size () - 2); |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
97 |
} |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
98 |
else |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
99 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
100 |
cur = param.find ("-"); |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
101 |
if (cur == 0) |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
102 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
103 |
param = param.substr (1, param.size () - 1); |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
104 |
} |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
105 |
else |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
106 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
107 |
// invalid argument. ignore. |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
108 |
continue; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
109 |
} |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
110 |
} |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
111 |
cur = param.find ("="); |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
112 |
std::string name, value; |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
113 |
if (cur == std::string::npos) |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
114 |
{ |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
115 |
name = param; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
116 |
value = ""; |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
117 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
118 |
else |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
119 |
{ |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
120 |
name = param.substr (0, cur); |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
121 |
value = param.substr (cur + 1, param.size () - (cur+1)); |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
122 |
} |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
123 |
HandleArgument (name, value); |
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
124 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
125 |
} |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff
changeset
|
126 |
|
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
127 |
void |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
128 |
CommandLine::PrintHelp (void) const |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
129 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
130 |
NS_LOG_FUNCTION (this); |
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
131 |
|
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
132 |
std::cout << "--PrintHelp: Print this help message." << std::endl; |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
133 |
std::cout << "--PrintGroups: Print the list of groups." << std::endl; |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
134 |
std::cout << "--PrintTypeIds: Print all TypeIds." << std::endl; |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
135 |
std::cout << "--PrintGroup=[group]: Print all TypeIds of group." << std::endl; |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
136 |
std::cout << "--PrintAttributes=[typeid]: Print all attributes of typeid." << std::endl; |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
137 |
std::cout << "--PrintGlobals: Print the list of globals." << std::endl; |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
138 |
if (!m_items.empty ()) |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
139 |
{ |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
140 |
std::cout << "User Arguments:" << std::endl; |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
141 |
for (Items::const_iterator i = m_items.begin (); i != m_items.end (); ++i) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
142 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
143 |
std::cout << " --" << (*i)->m_name << ": " << (*i)->m_help << std::endl; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
144 |
} |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
145 |
} |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
146 |
} |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
147 |
|
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
148 |
void |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
149 |
CommandLine::PrintGlobals (void) const |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
150 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
151 |
NS_LOG_FUNCTION (this); |
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
152 |
|
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
153 |
for (GlobalValue::Iterator i = GlobalValue::Begin (); i != GlobalValue::End (); ++i) |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
154 |
{ |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
155 |
std::cout << " --" << (*i)->GetName () << "=["; |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
156 |
Ptr<const AttributeChecker> checker = (*i)->GetChecker (); |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
157 |
StringValue v; |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
158 |
(*i)->GetValue (v); |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
159 |
std::cout << v.Get () << "]: " |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
160 |
<< (*i)->GetHelp () << std::endl; |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
161 |
} |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
162 |
} |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
163 |
|
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
164 |
void |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
165 |
CommandLine::PrintAttributes (std::string type) const |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
166 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
167 |
NS_LOG_FUNCTION (this); |
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
168 |
|
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
169 |
TypeId tid; |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
170 |
if (!TypeId::LookupByNameFailSafe (type, &tid)) |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
171 |
{ |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
172 |
NS_FATAL_ERROR ("Unknown type="<<type<<" in --PrintAttributes"); |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
173 |
} |
2693
56e28e34e109
TypeId::GetAttributeListN -> TypeId::GetAttributeN
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2629
diff
changeset
|
174 |
for (uint32_t i = 0; i < tid.GetAttributeN (); ++i) |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
175 |
{ |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
176 |
std::cout << " --"<<tid.GetAttributeFullName (i)<<"=["; |
7393
8c3dfe0be54d
use new API. kill old one.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
177 |
struct TypeId::AttributeInformation info = tid.GetAttribute (i); |
8c3dfe0be54d
use new API. kill old one.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
178 |
std::cout << info.initialValue->SerializeToString (info.checker) << "]: " |
8c3dfe0be54d
use new API. kill old one.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents:
7169
diff
changeset
|
179 |
<< info.help << std::endl; |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
180 |
} |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
181 |
} |
1702
0fbe74581141
Bug 81 (CommandLine::AddArgValue not working correctly)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1533
diff
changeset
|
182 |
|
0fbe74581141
Bug 81 (CommandLine::AddArgValue not working correctly)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1533
diff
changeset
|
183 |
|
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
184 |
void |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
185 |
CommandLine::PrintGroup (std::string group) const |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
186 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
187 |
NS_LOG_FUNCTION (this); |
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
188 |
|
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
189 |
for (uint32_t i = 0; i < TypeId::GetRegisteredN (); ++i) |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
190 |
{ |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
191 |
TypeId tid = TypeId::GetRegistered (i); |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
192 |
if (tid.GetGroupName () == group) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
193 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
194 |
std::cout << " --PrintAttributes=" <<tid.GetName ()<<std::endl; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
195 |
} |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
196 |
} |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
197 |
} |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
198 |
|
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
199 |
void |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
200 |
CommandLine::PrintTypeIds (void) const |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
201 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
202 |
NS_LOG_FUNCTION (this); |
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
203 |
|
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
204 |
for (uint32_t i = 0; i < TypeId::GetRegisteredN (); ++i) |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
205 |
{ |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
206 |
TypeId tid = TypeId::GetRegistered (i); |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
207 |
std::cout << " --PrintAttributes=" <<tid.GetName ()<<std::endl; |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
208 |
} |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
209 |
} |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
210 |
|
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
211 |
void |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
212 |
CommandLine::PrintGroups (void) const |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
213 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
214 |
NS_LOG_FUNCTION (this); |
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
215 |
|
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
216 |
std::list<std::string> groups; |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
217 |
for (uint32_t i = 0; i < TypeId::GetRegisteredN (); ++i) |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
218 |
{ |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
219 |
TypeId tid = TypeId::GetRegistered (i); |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
220 |
std::string group = tid.GetGroupName (); |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
221 |
if (group == "") |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
222 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
223 |
continue; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
224 |
} |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
225 |
bool found = false; |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
226 |
for (std::list<std::string>::const_iterator j = groups.begin (); j != groups.end (); ++j) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
227 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
228 |
if (*j == group) |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
229 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
230 |
found = true; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
231 |
break; |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
232 |
} |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
233 |
} |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
234 |
if (!found) |
7169
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
235 |
{ |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
236 |
groups.push_back (group); |
358f71a624d8
core coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7003
diff
changeset
|
237 |
} |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
238 |
} |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
239 |
for (std::list<std::string>::const_iterator k = groups.begin (); k != groups.end (); ++k) |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
240 |
{ |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
241 |
std::cout << " --PrintGroup="<<*k<<std::endl; |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
242 |
} |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
243 |
} |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
244 |
|
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
245 |
void |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
246 |
CommandLine::HandleArgument (std::string name, std::string value) const |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
247 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
248 |
NS_LOG_FUNCTION (this << name << value); |
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
249 |
|
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
250 |
NS_LOG_DEBUG ("Handle arg name="<<name<<" value="<<value); |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
251 |
if (name == "PrintHelp") |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
252 |
{ |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
253 |
// method below never returns. |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
254 |
PrintHelp (); |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7393
diff
changeset
|
255 |
std::exit (0); |
4490
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
256 |
} |
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
257 |
else if (name == "PrintGroups") |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
258 |
{ |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
259 |
// method below never returns. |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
260 |
PrintGroups (); |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7393
diff
changeset
|
261 |
std::exit (0); |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
262 |
} |
4490
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
263 |
else if (name == "PrintTypeIds") |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
264 |
{ |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
265 |
// method below never returns. |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
266 |
PrintTypeIds (); |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7393
diff
changeset
|
267 |
std::exit (0); |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
268 |
} |
4490
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
269 |
else if (name == "PrintGlobals") |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
270 |
{ |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
271 |
// method below never returns. |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
272 |
PrintGlobals (); |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7393
diff
changeset
|
273 |
std::exit (0); |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
274 |
} |
4490
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
275 |
else if (name == "PrintGroup") |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
276 |
{ |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
277 |
// method below never returns. |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
278 |
PrintGroup (value); |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7393
diff
changeset
|
279 |
std::exit (0); |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
280 |
} |
4490
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
281 |
else if (name == "PrintAttributes") |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
282 |
{ |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
283 |
// method below never returns. |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
284 |
PrintAttributes (value); |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7393
diff
changeset
|
285 |
std::exit (0); |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
286 |
} |
4490
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
287 |
else |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
288 |
{ |
4490
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
289 |
for (Items::const_iterator i = m_items.begin (); i != m_items.end (); ++i) |
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
290 |
{ |
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
291 |
if ((*i)->m_name == name) |
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
292 |
{ |
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
293 |
if (!(*i)->Parse (value)) |
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
294 |
{ |
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
295 |
std::cerr << "Invalid argument value: "<<name<<"="<<value << std::endl; |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7393
diff
changeset
|
296 |
std::exit (1); |
4490
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
297 |
} |
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
298 |
else |
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
299 |
{ |
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
300 |
return; |
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
301 |
} |
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
302 |
} |
6aa43c812fec
bug 561: CommandLine based programs should exit with non-zero return if bad parameters are given
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3929
diff
changeset
|
303 |
} |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
304 |
} |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
305 |
if (!Config::SetGlobalFailSafe (name, StringValue (value)) |
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2693
diff
changeset
|
306 |
&& !Config::SetDefaultFailSafe (name, StringValue (value))) |
2629
085df3e28a28
Fix parsing of GlobalValues as command line options.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2612
diff
changeset
|
307 |
{ |
085df3e28a28
Fix parsing of GlobalValues as command line options.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2612
diff
changeset
|
308 |
std::cerr << "Invalid command-line arguments: --"<<name<<"="<<value<<std::endl; |
085df3e28a28
Fix parsing of GlobalValues as command line options.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2612
diff
changeset
|
309 |
PrintHelp (); |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7393
diff
changeset
|
310 |
std::exit (1); |
2629
085df3e28a28
Fix parsing of GlobalValues as command line options.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2612
diff
changeset
|
311 |
} |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
312 |
} |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2195
diff
changeset
|
313 |
|
3929
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
314 |
bool |
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
315 |
CommandLine::CallbackItem::Parse (std::string value) |
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
316 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
317 |
NS_LOG_FUNCTION (this); |
3929
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
318 |
NS_LOG_DEBUG ("CommandLine::CallbackItem::Parse \"" << value << "\""); |
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
319 |
return m_callback (value); |
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
320 |
} |
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
321 |
|
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
322 |
void |
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
323 |
CommandLine::AddValue (const std::string &name, |
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
324 |
const std::string &help, |
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
325 |
Callback<bool, std::string> callback) |
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
326 |
{ |
9134
7a750f032acd
Clean up function logging of core module.
Maja Grubišić <maja.grubisic@live.com>
parents:
9063
diff
changeset
|
327 |
NS_LOG_FUNCTION (this << &name << &help << &callback); |
3929
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
328 |
CallbackItem *item = new CallbackItem (); |
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
329 |
item->m_name = name; |
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
330 |
item->m_help = help; |
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
331 |
item->m_callback = callback; |
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
332 |
m_items.push_back (item); |
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
333 |
} |
909b0a724ed3
Bug 289: CommandLine::AddValue is not wrapped
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2972
diff
changeset
|
334 |
|
5246
0974f3a8f379
Remove and replace CommandLine BVT (bug 675)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4490
diff
changeset
|
335 |
} // namespace ns3 |