appkit  1.5.1
RoadNarrows Robotics Application Kit
CmdCore.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: RoadNarrows Robotics Application Tool Kit
4 //
5 // Link: https://github.com/roadnarrows-robotics/rnr-sdk
6 //
7 // Library: librnr_appkit
8 //
9 // File: CommandLine.cxx
10 //
11 /*! \file
12  *
13  * \brief Command-Line parser class implementation
14  *
15  * \author Robin Knight (robin.knight@roadnarrows.com)
16  *
17  * \par Copyright
18  * \h_copy 2016-2017. RoadNarrows LLC.\n
19  * http://www.roadnarrows.com\n
20  * All Rights Reserved
21  *
22  * \par License:
23  * MIT
24  */
25 /*
26  * @EulaBegin@
27  *
28  * Permission is hereby granted, without written agreement and without
29  * license or royalty fees, to use, copy, modify, and distribute this
30  * software and its documentation for any purpose, provided that
31  * (1) The above copyright notice and the following two paragraphs
32  * appear in all copies of the source code and (2) redistributions
33  * including binaries reproduces these notices in the supporting
34  * documentation. Substantial modifications to this software may be
35  * copyrighted by their authors and need not follow the licensing terms
36  * described here, provided that the new terms are clearly indicated in
37  * all files where they apply.
38  *
39  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
40  * OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
41  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
42  * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
43  * EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
44  * THE POSSIBILITY OF SUCH DAMAGE.
45  *
46  * THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
47  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
48  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
49  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
50  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
51  *
52  * @EulaEnd@
53  */
54 ////////////////////////////////////////////////////////////////////////////////
55 
56 #include <stdio.h>
57 #include <unistd.h>
58 #include <stdlib.h>
59 #include <ctype.h>
60 
61 #include <iostream>
62 #include <sstream>
63 #include <string>
64 #include <locale>
65 #include <vector>
66 #include <set>
67 #include <map>
68 
69 #include "rnr/rnrconfig.h"
70 #include "rnr/log.h"
71 
72 #include "rnr/appkit/CmdCore.h"
73 
74 using namespace std;
75 using namespace rnr;
76 using namespace rnr::cmd;
77 
78 namespace rnr
79 {
80  namespace cmd
81  {
82  const string emptystring; ///< empty string
83  const string undefstring("undef"); ///< empty string
84 
85  void DataSectCore::dealloc(void *p)
86  {
87  if( p != NULL )
88  {
89  delete (DataSectCore *)p;
90  }
91  }
92 
93  bool isIdentifier(const string &str)
94  {
95  if( str.size() == 0 )
96  {
97  return false;
98  }
99 
100  // start character
101  if( !isalpha(str[0]) && (str[0] != '_') )
102  {
103  return false;
104  }
105 
106  // subsequent characters
107  for(size_t i = 1; i < str.size(); ++i)
108  {
109  if( !isalnum(str[i]) && (str[i] != '_') )
110  {
111  return false;
112  }
113  }
114 
115  return true;
116  }
117 
118  } // namespace cmd
119 } // namespace rnr
120 
const string undefstring("undef")
empty string
Commands.
Definition: CmdAddOns.h:81
Command line core data types.
bool isIdentifier(const std::string &str)
Test if string is a valid identifier.
RoadNarrows Robotics.
Definition: Camera.h:74
Core data section type.
Definition: CmdCore.h:148
const std::string emptystring
"" empty string
Definition: CmdCore.cxx:82