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