Rename translation units containing main() to main.cpp

Also unify style of argv declaration

Change-Id: I1dcb8689b1cd38e042a0b1f05be7f98bd2d487ed
This commit is contained in:
Davide Pesavento committed 2019-03-18 18:24:20 -04:00
1 parent e4687a1d57
commit da85e25e59
10 files changed
+46 -59

No files matched your search

+15 -11
View File
@@ -59,25 +59,29 @@ C++ code SHOULD conform to
### Namespace
Types in each tool SHOULD be declared in a sub-namespace under `namespace ndn`.
Types in each tool SHOULD be declared in a sub-namespace inside `namespace ndn`.
For example, a tool in `tools/foo` directory has namespace `ndn::foo`.
This allows the tool to reference ndn-cxx types with unqualified name lookup.
This also prevents name conflicts between ndn-cxx and tools.
Types in `core/` SHOULD be declared directly under `namespace ndn`,
Types in `core/` SHOULD be declared directly inside `namespace ndn`,
or in a sub-namespace if desired.
`using namespace` SHOULD NOT be used except within block scope.
`using namespace` SHOULD NOT be used except in block scope.
### main Function
The main function of a program SHOULD be declared within its sub-namespace.
This allows it to reference types in ndn-cxx and the tool with unqualified name lookup.
The `main` function of a program SHOULD be declared as a static function in
the namespace of the corresponding tool. This allows referencing types in
ndn-cxx and the tool via unqualified name lookup.
Then, another main function in global namespace needs to be defined
to call the main function in sub-namespace.
Then, another (non-static) `main` function must be defined in the global
namespace, and from there call the `main` function in the tool namespace.
For example:
These two functions SHOULD appear in a file named `main.cpp` in the tool's
subdirectory.
Example:
namespace ndn {
namespace foo {
@@ -92,8 +96,8 @@ For example:
run();
};
int
main(int argc, char** argv)
static int
main(int argc, char* argv[])
{
Face face;
Bar program(face);
@@ -105,7 +109,7 @@ For example:
} // namespace ndn
int
main(int argc, char** argv)
main(int argc, char* argv[])
{
return ndn::foo::main(argc, argv);
}
@@ -46,7 +46,7 @@ namespace ndn {
namespace chunks {
static int
main(int argc, char** argv)
main(int argc, char* argv[])
{
std::string programName(argv[0]);
Options options;
@@ -305,7 +305,7 @@ main(int argc, char** argv)
} // namespace ndn
int
main(int argc, char** argv)
main(int argc, char* argv[])
{
return ndn::chunks::main(argc, argv);
}
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2016-2017, Regents of the University of California,
* Copyright (c) 2016-2019, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -47,7 +47,7 @@ usage(std::ostream& os, const std::string& programName, const po::options_descri
}
static int
main(int argc, char** argv)
main(int argc, char* argv[])
{
std::string programName = argv[0];
std::string prefix;
@@ -150,7 +150,7 @@ main(int argc, char** argv)
} // namespace ndn
int
main(int argc, char** argv)
main(int argc, char* argv[])
{
return ndn::chunks::main(argc, argv);
}
+4 -4
View File
@@ -5,24 +5,24 @@ def build(bld):
bld.objects(
target='ndncatchunks-objects',
source=bld.path.ant_glob('catchunks/*.cpp', excl='catchunks/ndncatchunks.cpp'),
source=bld.path.ant_glob('catchunks/*.cpp', excl='catchunks/main.cpp'),
use='core-objects')
bld.program(
target='../../bin/ndncatchunks',
name='ndncatchunks',
source='catchunks/ndncatchunks.cpp',
source='catchunks/main.cpp',
use='ndncatchunks-objects')
bld.objects(
target='ndnputchunks-objects',
source=bld.path.ant_glob('putchunks/*.cpp', excl='putchunks/ndnputchunks.cpp'),
source=bld.path.ant_glob('putchunks/*.cpp', excl='putchunks/main.cpp'),
use='core-objects')
bld.program(
target='../../bin/ndnputchunks',
name='ndnputchunks',
source='putchunks/ndnputchunks.cpp',
source='putchunks/main.cpp',
use='ndnputchunks-objects')
## (for unit tests)
+3 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2017, Regents of the University of California.
/*
* Copyright (c) 2014-2019, Regents of the University of California.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -114,7 +114,7 @@ main(int argc, char* argv[])
} // namespace ndn
int
main(int argc, char** argv)
main(int argc, char* argv[])
{
return ndn::dissect::main(argc, argv);
}
+2 -19
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2018, Regents of the University of California.
* Copyright (c) 2011-2019, Regents of the University of California.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -16,23 +16,6 @@
* You should have received a copy of the GNU General Public License along with
* ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Copyright (c) 2011-2014, Regents of the University of California,
*
* This file is part of ndndump, the packet capture and analysis tool for Named Data
* Networking (NDN).
*
* ndndump is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* ndndump is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* ndndump, e.g., in COPYING file. If not, see <http://www.gnu.org/licenses/>.
**/
#include "ndndump.hpp"
#include "core/version.hpp"
@@ -157,7 +140,7 @@ main(int argc, char* argv[])
} // namespace ndn
int
main(int argc, char** argv)
main(int argc, char* argv[])
{
return ndn::dump::main(argc, argv);
}
+2 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2018, Regents of the University of California,
* Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -171,7 +171,7 @@ main(int argc, char* argv[])
} // namespace ndn
int
main(int argc, char** argv)
main(int argc, char* argv[])
{
return ndn::peek::main(argc, argv);
}
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2017, Arizona Board of Regents.
/*
* Copyright (c) 2014-2019, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -136,15 +136,15 @@ static void
usage(const boost::program_options::options_description& options)
{
std::cout << "Usage: ndnping [options] ndn:/name/prefix\n"
"\n"
"Ping a NDN name prefix using Interests with name ndn:/name/prefix/ping/number.\n"
"The numbers in the Interests are randomly generated unless specified.\n"
"\n";
std::cout << options;
"\n"
"Ping a NDN name prefix using Interests with name ndn:/name/prefix/ping/number.\n"
"The numbers in the Interests are randomly generated unless specified.\n"
"\n"
<< options;
exit(2);
}
int
static int
main(int argc, char* argv[])
{
Options options;
@@ -269,7 +269,7 @@ main(int argc, char* argv[])
} // namespace ndn
int
main(int argc, char** argv)
main(int argc, char* argv[])
{
return ndn::ping::client::main(argc, argv);
}
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2015-2018, Arizona Board of Regents.
* Copyright (c) 2015-2019, Arizona Board of Regents.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -187,7 +187,7 @@ main(int argc, char* argv[])
} // namespace ndn
int
main(int argc, char** argv)
main(int argc, char* argv[])
{
return ndn::ping::server::main(argc, argv);
}
+4 -4
View File
@@ -5,24 +5,24 @@ def build(bld):
bld.objects(
target='ping-client-objects',
source=bld.path.ant_glob('client/*.cpp', excl='client/ndn-ping.cpp'),
source=bld.path.ant_glob('client/*.cpp', excl='client/main.cpp'),
use='core-objects')
bld.program(
target='../../bin/ndnping',
name='ndnping',
source='client/ndn-ping.cpp',
source='client/main.cpp',
use='ping-client-objects')
bld.objects(
target='ping-server-objects',
source=bld.path.ant_glob('server/*.cpp', excl='server/ndn-ping-server.cpp'),
source=bld.path.ant_glob('server/*.cpp', excl='server/main.cpp'),
use='core-objects')
bld.program(
target='../../bin/ndnpingserver',
name='ndnpingserver',
source='server/ndn-ping-server.cpp',
source='server/main.cpp',
use='ping-server-objects')
## (for unit tests)