This is Unofficial EPICS BASE Doxygen Site
epics::nt::NTID Class Reference

Utility class for parsing a type ID that follows the NT type ID conventions. More...

#include "ntid.h"

Public Member Functions

 NTID (const std::string &id)
 
std::string getFullName ()
 
std::string getQualifiedName ()
 
std::string getNamespace ()
 
std::string getName ()
 
std::string getVersion ()
 
std::string getMajorVersionString ()
 
bool hasMajorVersion ()
 
int getMajorVersion ()
 
std::string getMinorVersionString ()
 
bool hasMinorVersion ()
 
int getMinorVersion ()
 

Detailed Description

Utility class for parsing a type ID that follows the NT type ID conventions.

An NT type ID will be of the from

epics:nt/<type-name>:<Major>.<Minor>

e.g.

epics:nt/NTNDArray:1.2
Author
dgh

Definition at line 28 of file ntid.h.

Constructor & Destructor Documentation

epics::nt::NTID::NTID ( const std::string &  id)

Creates an NTID from the specified type ID.

Parameters
idthe the ID to be parsed.
Returns
NTNDArray instance on success, null otherwise.

Definition at line 16 of file ntid.cpp.

17  : fullName(id),
18  qualifiedName(BAD_NAME),
19  namespaceStr(BAD_NAME),
20  name(BAD_NAME),
21  version(BAD_NAME),
22  nsSepIndex(std::string::npos),
23  versionSepIndex(std::string::npos),
24  nsQualified(false),
25  hasVersion(false),
26  endMajorIndex(0),
27  majorVersionStr(BAD_NAME),
28  majorVersionParsed(false),
29  hasMajor(false),
30  majorVersion(0),
31 
32  endMinorIndex(0),
33  minorVersionStr(BAD_NAME),
34  minorVersionParsed(false),
35  hasMinor(false),
36  minorVersion(0)
37  {
38  nsSepIndex = id.find('/');
39  nsQualified = nsSepIndex != std::string::npos;
40  size_t startIndex = nsQualified ? nsSepIndex+1 : 0;
41  versionSepIndex = id.find(':', startIndex);
42  hasVersion = versionSepIndex != std::string::npos;
43  }

Member Function Documentation

std::string epics::nt::NTID::getFullName ( )

Returns the full name of the id, i.e. the original ID

For example above returns "epics:nt/NTNDArray:1.2".

Returns
the full name

Definition at line 45 of file ntid.cpp.

45 { return fullName; }
int epics::nt::NTID::getMajorVersion ( )

Returns the Major version as an integer.

For example above return 1.

Returns
the Major string

Definition at line 135 of file ntid.cpp.

136  {
137  // call hasMajorVersion() to calculate values
138  hasMajorVersion();
139  return majorVersion;
140  }
bool hasMajorVersion()
Definition: ntid.cpp:118
std::string epics::nt::NTID::getMajorVersionString ( )

Returns the Major version as a string.

For example above return "1".

Returns
the Major string

Definition at line 100 of file ntid.cpp.

101  {
102  if (majorVersionStr == BAD_NAME)
103  {
104  if (hasVersion)
105  {
106  endMajorIndex = fullName.find('.', versionSepIndex+1);
107  majorVersionStr = (endMajorIndex != std::string::npos)
108  ? fullName.substr(versionSepIndex+1, endMajorIndex-(versionSepIndex+1)) :
109  fullName.substr(versionSepIndex+1);
110  }
111  else
112  majorVersionStr = "";
113  }
114  return majorVersionStr;
115  }
int epics::nt::NTID::getMinorVersion ( )

Returns the Minor version as an integer.

For example above return 1.

Returns
the Minor string

Definition at line 180 of file ntid.cpp.

181  {
182  // call hasMinorVersion() to calculate values
183  hasMinorVersion();
184  return minorVersion;
185  }
bool hasMinorVersion()
Definition: ntid.cpp:163
std::string epics::nt::NTID::getMinorVersionString ( )

Returns the Major version as a string.

For example above return "1".

Returns
the Major string

Definition at line 143 of file ntid.cpp.

144  {
145  // call hasMinorVersion() to calculate start of minor
147  if (minorVersionStr == BAD_NAME)
148  {
149  if (hasVersion && endMajorIndex != std::string::npos)
150  {
151  endMinorIndex = fullName.find('.', endMajorIndex+1);
152  minorVersionStr = (endMinorIndex != std::string::npos)
153  ? fullName.substr(endMajorIndex+1, endMinorIndex-(endMajorIndex+1)) :
154  fullName.substr(endMajorIndex+1);
155  }
156  else
157  minorVersionStr = "";
158  }
159  return minorVersionStr;
160  }
std::string getMajorVersionString()
Definition: ntid.cpp:100
std::string epics::nt::NTID::getName ( )

Returns the unqualified name, without namespace or version.

For example above return "NTNDArray".

Returns
the unqualified name

Definition at line 68 of file ntid.cpp.

69  {
70  if (name == BAD_NAME)
71  {
72  if (hasVersion)
73  {
74  size_t startIndex = nsQualified ? nsSepIndex+1 : 0;
75  name = fullName.substr(startIndex, versionSepIndex);
76  }
77  else if (nsQualified)
78  {
79  name = fullName.substr(nsSepIndex+1);
80  }
81  else
82  {
83  name = fullName;
84  }
85  }
86  return name;
87  }
std::string epics::nt::NTID::getNamespace ( )

Returns the namespace

For example above return "epics:nt".

Returns
the namespace

Definition at line 58 of file ntid.cpp.

59  {
60  if (namespaceStr == BAD_NAME)
61  {
62  namespaceStr = nsQualified ?
63  fullName.substr(0, nsSepIndex) : "";
64  }
65  return namespaceStr;
66  }
std::string epics::nt::NTID::getQualifiedName ( )

Returns the fully qualified name including namespaces, but excluding version numbers.

For example above return "epics:nt/NTNDArray"

Returns
the fully qualified name

Definition at line 47 of file ntid.cpp.

48  {
49  if (qualifiedName == BAD_NAME)
50  {
51  qualifiedName = hasVersion ?
52  fullName.substr(0, versionSepIndex) : fullName;
53  }
54  return qualifiedName;
55  }
std::string epics::nt::NTID::getVersion ( )

Returns the version as a string.

For example above return "NTNDArray".

Returns
the the version string

Definition at line 90 of file ntid.cpp.

91  {
92  if (version == BAD_NAME)
93  {
94  version = (hasVersion) ? fullName.substr(versionSepIndex+1) : "";
95  }
96  return version;
97  }
bool epics::nt::NTID::hasMajorVersion ( )

Does the ID contain a major version and is it a number.

Returns
true if it contains a major version number

Definition at line 118 of file ntid.cpp.

119  {
120  if (hasVersion && !majorVersionParsed)
121  {
122  try {
124  uint32_t mv;
126  majorVersion = static_cast<int>(mv);
127  hasMajor = true;
128  } catch (...) {}
129  majorVersionParsed = true;
130  }
131  return hasMajor;
132  }
void parseToPOD(const char *in, boolean *out)
Definition: parseToPOD.cpp:110
std::string getMajorVersionString()
Definition: ntid.cpp:100
bool epics::nt::NTID::hasMinorVersion ( )

Does the ID contain a minor version and is it a number.

Returns
true if it contains a minor version number

Definition at line 163 of file ntid.cpp.

164  {
165  if (hasVersion && !minorVersionParsed)
166  {
167  try {
169  uint32_t mv;
171  minorVersion = static_cast<int>(mv);
172  hasMinor = true;
173  } catch (...) {}
174  minorVersionParsed = true;
175  }
176  return hasMinor;
177  }
std::string getMinorVersionString()
Definition: ntid.cpp:143
void parseToPOD(const char *in, boolean *out)
Definition: parseToPOD.cpp:110

The documentation for this class was generated from the following files: