A Discrete-Event Network Simulator
API
build-version-example.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Lawrence Livermore National Laboratory
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
18  */
19 
20 #include "ns3/command-line.h"
21 #include "ns3/version.h"
22 
23 #include <iomanip>
24 #include <iostream>
25 #include <string>
26 
33 using namespace ns3;
34 
35 int
36 main(int argc, char* argv[])
37 {
38  CommandLine cmd(__FILE__);
39  cmd.Usage("Version class example program.\n"
40  "\n"
41  "This program demonstrates the various outputs from the Version class");
42  cmd.Parse(argc, argv);
43 
44  std::cout << std::endl;
45  std::cout << cmd.GetName() << ":" << std::endl;
46 
47  // Print the source version used to build this example
48  std::cout << "Program Version (according to CommandLine): ";
49  cmd.PrintVersion(std::cout);
50  std::cout << std::endl;
51 
53  std::cout << "Version fields:\n"
54  << "LongVersion: " << version.LongVersion() << "\n"
55  << "ShortVersion: " << version.ShortVersion() << "\n"
56  << "BuildSummary: " << version.BuildSummary() << "\n"
57  << "VersionTag: " << version.VersionTag() << "\n"
58  << "Major: " << version.Major() << "\n"
59  << "Minor: " << version.Minor() << "\n"
60  << "Patch: " << version.Patch() << "\n"
61  << "ReleaseCandidate: " << version.ReleaseCandidate() << "\n"
62  << "ClosestAncestorTag: " << version.ClosestAncestorTag() << "\n"
63  << "TagDistance: " << version.TagDistance() << "\n"
64  << "CommitHash: " << version.CommitHash() << "\n"
65  << "BuildProfile: " << version.BuildProfile() << "\n"
66  << "WorkingTree: " << (version.DirtyWorkingTree() ? "dirty" : "clean")
67  << std::endl;
68 
69  return 0;
70 }
Parse command-line arguments.
Definition: command-line.h:232
Helper class providing functions to access various parts of the version string, as well as functions ...
Definition: version.h:102
string version
Definition: conf.py:52
Every class exported by the ns3 library is enclosed in the ns3 namespace.
cmd
Definition: second.py:40