Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
dynashell_util.h File Reference

Dynamixel shell utilities. More...

#include <stdio.h>
#include <cstring>
#include <iostream>
#include <fstream>
#include <vector>
#include "rnr/rnrconfig.h"
#include "rnr/opts.h"
#include "rnr/log.h"
#include "Dynamixel/Dynamixel.h"
#include "Dynamixel/DynaComm.h"
#include "Dynamixel/DynaChain.h"

Go to the source code of this file.

Macros

#define NEWSTR(s)   newstr(s)
 Allocate a new duplicated string convenience macro. More...
 
#define DELSTR(s)   do { if( s != NULL ) { delstr(s); s = NULL; } } while(0)
 Delete an allocated string convenience macro. More...
 
#define DELOBJ(p)   do { if( p != NULL ) { delete p; p = NULL; } } while(0)
 Delete an allocated object convenience macro. More...
 

Functions

char * newstr (const char *s)
 Allocate a new duplicated string utility. More...
 
void delstr (const char *s)
 A safer string delete utility. More...
 

Detailed Description

Dynamixel shell utilities.

LastChangedDate
2015-01-12 10:56:06 -0700 (Mon, 12 Jan 2015)
Rev
3845
Author
Robin Knight (robin.nosp@m..kni.nosp@m.ght@r.nosp@m.oadn.nosp@m.arrow.nosp@m.s.co.nosp@m.m)

Definition in file dynashell_util.h.

Macro Definition Documentation

#define DELOBJ (   p)    do { if( p != NULL ) { delete p; p = NULL; } } while(0)

Delete an allocated object convenience macro.

The value p is set to NULL after deletion.

Parameters
pPointer to the object to delete.

Definition at line 100 of file dynashell_util.h.

Referenced by DynaShellCmdDestroy::Exec(), DynaRecording::SetDate(), and DynaRecording::~DynaRecording().

#define DELSTR (   s)    do { if( s != NULL ) { delstr(s); s = NULL; } } while(0)

Delete an allocated string convenience macro.

The value s is set to NULL after deletion.

Parameters
sPointer to the string to delete.

Definition at line 91 of file dynashell_util.h.

Referenced by ShScript::~ShScript().

#define NEWSTR (   s)    newstr(s)

Allocate a new duplicated string convenience macro.

Parameters
sThe null-terminated string to duplicate.
Returns
Returns pointer to allocated string if s is not NULL and the length of s > 0.
Otherwise returns NULL.

Definition at line 82 of file dynashell_util.h.

Referenced by ShScript::ShScript().

Function Documentation

void delstr ( const char *  s)
inline

A safer string delete utility.

Parameters
sString to delete.

Definition at line 135 of file dynashell_util.h.

136 {
137  if( s != NULL )
138  {
139  delete[] (char *)s;
140  }
141 }
char* newstr ( const char *  s)
inline

Allocate a new duplicated string utility.

Parameters
sString to duplicate.
Returns
Returns pointer to allocated string if s is not NULL and the length of s > 0.
Otherwise returns NULL.

Definition at line 115 of file dynashell_util.h.

116 {
117  char *t;
118  if( (s != NULL) && (*s != 0) )
119  {
120  t = new char[strlen(s)+1];
121  strcpy(t, s);
122  }
123  else
124  {
125  t = NULL;
126  }
127  return t;
128 }
Definition: t.py:1