C++/CLI Sample
Demonstrates how to create a C++/CLI library using the VideoXpert SDK
CPPCli::Utils Class Reference

Provides commonly used methods. More...

#include <Utils.h>

Static Public Member Functions

static const char * GetDateFormat ()
 
static const char * ConvertSysString (System::String^ sysString)
 Convert a system string to a char. More...
 
static char * ConvertSysStringNonConst (System::String^ sysString)
 Convert a system string to a char. More...
 
static std::string ConvertSysStringStdString (System::String^ sysString)
 Convert a system string to a standard string. More...
 
static System::DateTime ConvertCharToDateTime (char *dateTimeString)
 Convert a char to a DateTime. More...
 
static const char * ConvertDateTimeToChar (System::DateTime dateTime)
 Convert a DateTime to a char. More...
 
static char * ConvertDateTimeToCharNonConst (System::DateTime dateTime)
 Convert a DateTime to a char. More...
 
static const char * ConvertDateTimeToTimeChar (System::DateTime dateTime)
 Convert a DateTime to a char in TimeOfDay format. More...
 
static char * ConvertDateTimeToTimeCharNonConst (System::DateTime dateTime)
 Convert a DateTime to a char in TimeOfDay format. More...
 
static System::DateTime ConvertTimeCharToDateTime (char *timeString)
 Convert a char to a DateTime using TimeOfDay format. More...
 

Detailed Description

Provides commonly used methods.

Definition at line 224 of file Utils.h.

Member Function Documentation

static System::DateTime CPPCli::Utils::ConvertCharToDateTime ( char *  dateTimeString)
inlinestatic

Convert a char to a DateTime.

Parameters
dateTimeStringThe date string.
Returns
Default DateTime if it fails, else the parsed DateTime.

Definition at line 262 of file Utils.h.

262  {
263  System::String^ value = gcnew System::String(dateTimeString);
264  System::String^ format = gcnew System::String(GetDateFormat());
265  if (value == System::String::Empty)
266  return System::DateTime();
267 
268  System::DateTime timeValue;
269  System::Globalization::CultureInfo^ culture = System::Globalization::CultureInfo::InvariantCulture;
270  System::DateTime::TryParseExact(value, format, culture, System::Globalization::DateTimeStyles::None, timeValue);
271  timeValue = System::DateTime::SpecifyKind(timeValue, System::DateTimeKind::Utc);
272  return timeValue;
273  }
static const char * GetDateFormat()
Definition: Utils.h:226
static const char* CPPCli::Utils::ConvertDateTimeToChar ( System::DateTime  dateTime)
inlinestatic

Convert a DateTime to a char.

Parameters
dateTimeThe DateTime.
Returns
The DateTime as a char.

Definition at line 280 of file Utils.h.

280  {
281  dateTime = dateTime.ToUniversalTime();
282  System::String^ timeString = dateTime.ToString(gcnew System::String(GetDateFormat()));
283  msclr::interop::marshal_context^ ctx = gcnew msclr::interop::marshal_context();
284  return ctx->marshal_as<const char*>(timeString);
285  }
static const char * GetDateFormat()
Definition: Utils.h:226
static char* CPPCli::Utils::ConvertDateTimeToCharNonConst ( System::DateTime  dateTime)
inlinestatic

Convert a DateTime to a char.

Parameters
dateTimeThe DateTime.
Returns
The DateTime as a char.

Definition at line 292 of file Utils.h.

292  {
293  dateTime = dateTime.ToUniversalTime();
294  System::String^ timeString = dateTime.ToString(gcnew System::String(GetDateFormat()));
295  msclr::interop::marshal_context^ ctx = gcnew msclr::interop::marshal_context();
296  return (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(timeString);
297  }
static const char * GetDateFormat()
Definition: Utils.h:226
static const char* CPPCli::Utils::ConvertDateTimeToTimeChar ( System::DateTime  dateTime)
inlinestatic

Convert a DateTime to a char in TimeOfDay format.

Parameters
dateTimeThe DateTime.
Returns
The DateTime as a char in TimeOfDay format.

Definition at line 304 of file Utils.h.

304  {
305  System::String^ timeString = dateTime.ToString(gcnew System::String("HH:mm:ss"));
306  msclr::interop::marshal_context^ ctx = gcnew msclr::interop::marshal_context();
307  return ctx->marshal_as<const char*>(timeString);
308  }
static char* CPPCli::Utils::ConvertDateTimeToTimeCharNonConst ( System::DateTime  dateTime)
inlinestatic

Convert a DateTime to a char in TimeOfDay format.

Parameters
dateTimeThe DateTime.
Returns
The DateTime as a char in TimeOfDay format.

Definition at line 315 of file Utils.h.

315  {
316  System::String^ timeString = dateTime.ToString(gcnew System::String("HH:mm:ss"));
317  msclr::interop::marshal_context^ ctx = gcnew msclr::interop::marshal_context();
318  return (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(timeString);
319  }
static const char* CPPCli::Utils::ConvertSysString ( System::String^  sysString)
inlinestatic

Convert a system string to a char.

Parameters
sysStringThe system string.
Returns
Null if it fails, else the converted string.

Definition at line 233 of file Utils.h.

233  {
234  msclr::interop::marshal_context^ ctx = gcnew msclr::interop::marshal_context();
235  return ctx->marshal_as<const char*>(sysString);
236  }
static char* CPPCli::Utils::ConvertSysStringNonConst ( System::String^  sysString)
inlinestatic

Convert a system string to a char.

Parameters
sysStringThe system string.
Returns
Null if it fails, else the converted string.

Definition at line 243 of file Utils.h.

243  {
244  return (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(sysString);
245  }
static std::string CPPCli::Utils::ConvertSysStringStdString ( System::String^  sysString)
inlinestatic

Convert a system string to a standard string.

Parameters
sysStringThe system string.
Returns
Null if it fails, else the converted string.

Definition at line 252 of file Utils.h.

252  {
253  msclr::interop::marshal_context^ ctx = gcnew msclr::interop::marshal_context();
254  return ctx->marshal_as<std::string>(sysString);
255  }
static System::DateTime CPPCli::Utils::ConvertTimeCharToDateTime ( char *  timeString)
inlinestatic

Convert a char to a DateTime using TimeOfDay format.

Parameters
timeStringThe time string.
Returns
Default DateTime if it fails, else the parsed DateTime.

Definition at line 326 of file Utils.h.

326  {
327  System::DateTime parsedTime;
328  System::String^ value = gcnew System::String(timeString);
329  if (value == System::String::Empty)
330  return parsedTime;
331 
332  array<System::String^>^ formats = gcnew array<System::String^>(2);
333  formats[0] = gcnew System::String("HH:mm:ss");
334  formats[1] = gcnew System::String("HH:mm:ss.fff");
335  System::DateTime::TryParseExact(value, formats, System::Globalization::CultureInfo::InvariantCulture, System::Globalization::DateTimeStyles::None, parsedTime);
336 
337  return parsedTime;
338  }
static const char* CPPCli::Utils::GetDateFormat ( )
inlinestatic

Definition at line 226 of file Utils.h.

226 { return "yyyy-MM-dd'T'HH:mm:ss.fff'Z'"; }

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