SafetyProfileStreams.cpp

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 #include "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/
00008 
00009 #include "dds/DCPS/SafetyProfileStreams.h"
00010 
00011 namespace OpenDDS {
00012 namespace DCPS {
00013 
00014 OPENDDS_STRING
00015 to_dds_string(::CORBA::UShort to_convert)
00016 {
00017   const char* fmt = "%hu";
00018   const int buff_size = 5 + 1; // note +1 for null terminator
00019   char buf[buff_size];
00020   ACE_OS::snprintf(&buf[0], buff_size, fmt, to_convert);
00021   return OPENDDS_STRING(buf);
00022 }
00023 
00024 OPENDDS_STRING
00025 to_dds_string(int to_convert)
00026 {
00027   const char* fmt = "%d";
00028   const int buff_size = 20 + 1; // note +1 for null terminator
00029   char buf[buff_size];
00030   ACE_OS::snprintf(&buf[0], buff_size, fmt, to_convert);
00031   return OPENDDS_STRING(buf);
00032 }
00033 
00034 OPENDDS_STRING
00035 to_dds_string(unsigned int to_convert, bool as_hex)
00036 {
00037   const char* fmt;
00038   if (as_hex) {
00039     fmt = "%02x";
00040     const int buff_size = 3; // note +1 for null terminator
00041     char buf[buff_size];
00042     ACE_OS::snprintf(&buf[0], buff_size, fmt, to_convert);
00043     return OPENDDS_STRING(buf);
00044   } else {
00045     fmt = "%u";
00046     const int buff_size = 20 + 1; // note +1 for null terminator
00047     char buf[buff_size];
00048     ACE_OS::snprintf(&buf[0], buff_size, fmt, to_convert);
00049     return OPENDDS_STRING(buf);
00050   }
00051 }
00052 
00053 OPENDDS_STRING
00054 to_dds_string(long to_convert)
00055 {
00056   const char* fmt = "%ld";
00057   const int buff_size = 20 + 1; // note +1 for null terminator
00058   char buf[buff_size];
00059   ACE_OS::snprintf(&buf[0], buff_size, fmt, to_convert);
00060   return OPENDDS_STRING(buf);
00061 }
00062 
00063 OPENDDS_STRING
00064 to_dds_string(long long to_convert)
00065 {
00066   const char* fmt = "%lld";
00067   const int buff_size = 20 + 1; // note +1 for null terminator
00068   char buf[buff_size];
00069   ACE_OS::snprintf(&buf[0], buff_size, fmt, to_convert);
00070   return OPENDDS_STRING(buf);
00071 }
00072 
00073 OPENDDS_STRING
00074 to_dds_string(unsigned long long to_convert, bool as_hex)
00075 {
00076   const char* fmt;
00077   if (as_hex) {
00078     fmt = "%0llx";
00079   } else {
00080     fmt = "%llu";
00081   }
00082   const int buff_size = 20 + 1; // note +1 for null terminator
00083   char buf[buff_size];
00084   ACE_OS::snprintf(&buf[0], buff_size, fmt, to_convert);
00085   return OPENDDS_STRING(buf);
00086 }
00087 
00088 OPENDDS_STRING
00089 to_dds_string(unsigned long to_convert, bool as_hex)
00090 {
00091   const char* fmt;
00092   if (as_hex) {
00093     fmt = "%0lx";
00094   } else {
00095     fmt = "%lu";
00096   }
00097   const int buff_size = 20 + 1; // note +1 for null terminator
00098   char buf[buff_size];
00099   ACE_OS::snprintf(&buf[0], buff_size, fmt, to_convert);
00100   return OPENDDS_STRING(buf);
00101 }
00102 
00103 } // namespace DCPS
00104 } // namespace OpenDDS

Generated on Fri Feb 12 20:05:26 2016 for OpenDDS by  doxygen 1.4.7