Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / TAO_IDL / util / idl_version.cpp
bloba5499d663e657251ed0025aba9dbc60ce146b373
1 /**
2 * Source File for Tracking IDL Versions
4 * Header File Counterpart is include/idl_version.h
5 */
7 #include "ace/OS_NS_string.h"
8 #include "idl_version.h"
10 namespace {
11 const char * idlVersionNames[IDL_VERSION_COUNT] = {
12 "Invalid",
13 "3",
14 "4"
17 /**
18 * Values for __TAO_IDL_IDL_VERSION. Should work like __TAO_IDL does.
20 const char * idl_version_macros[IDL_VERSION_COUNT] = {
21 "0x0",
22 "0x030000",
23 "0x040000"
27 IdlVersion::IdlVersion () : version_(DEFAULT_DEFAULT_IDL_VERSION)
31 IdlVersion::IdlVersion (SpecificIdlVersion version)
33 this->version (version);
36 SpecificIdlVersion IdlVersion::version () const
38 return version_;
41 void IdlVersion::version (SpecificIdlVersion version)
43 version_ = version < IDL_VERSION_COUNT ? version : IDL_VERSION_INVALID;
46 bool IdlVersion::is_valid () const
48 return version_ != IDL_VERSION_INVALID;
51 const char * IdlVersion::to_string () const
53 return idlVersionNames[version_];
56 void IdlVersion::from_string (const char * version)
58 if (version)
60 for (int i = 0; i < IDL_VERSION_COUNT; i++)
62 if (!ACE_OS::strcmp (version, idlVersionNames[i]))
64 version_ = static_cast<SpecificIdlVersion> (i);
65 return;
69 version_ = IDL_VERSION_INVALID;
72 const char * IdlVersion::to_macro () const
74 return idl_version_macros[version_];
77 IdlVersion::operator SpecificIdlVersion () const
79 return version_;
82 bool IdlVersion::operator== (SpecificIdlVersion other) const
84 return version_ == other;
87 bool IdlVersion::operator!= (SpecificIdlVersion other) const
89 return version_ != other;
92 bool IdlVersion::operator> (SpecificIdlVersion other) const
94 return version_ > other;
97 bool IdlVersion::operator>= (SpecificIdlVersion other) const
99 return version_ >= other;
102 bool IdlVersion::operator< (SpecificIdlVersion other) const
104 return version_ < other;
107 bool IdlVersion::operator<= (SpecificIdlVersion other) const
109 return version_ <= other;