FreeSWITCH API Documentation  1.7.0
Public Member Functions | Protected Attributes
Stream Class Reference

#include <switch_cpp.h>

+ Collaboration diagram for Stream:

Public Member Functions

 Stream (void)
 
 Stream (switch_stream_handle_t *)
 
virtual ~Stream ()
 
const char * read (int *len)
 
void write (const char *data)
 
void raw_write (const char *data, int len)
 
const char * get_data (void)
 
 Stream (void)
 
 Stream (switch_stream_handle_t *)
 
virtual ~Stream ()
 
const char * read (int *len)
 
void write (const char *data)
 
void raw_write (const char *data, int len)
 
const char * get_data (void)
 

Protected Attributes

switch_stream_handle_t mystream
 
switch_stream_handle_tstream_p
 
int mine
 

Detailed Description

Definition at line 143 of file switch_cpp.h.

Constructor & Destructor Documentation

Stream::Stream ( void  )

Definition at line 541 of file switch_cpp.cpp.

References mine, mystream, stream_p, and SWITCH_STANDARD_STREAM.

542 {
544  stream_p = &mystream;
545  mine = 1;
546 }
switch_stream_handle_t mystream
Definition: switch_cpp.h:145
int mine
Definition: switch_cpp.h:147
switch_stream_handle_t * stream_p
Definition: switch_cpp.h:146
#define SWITCH_STANDARD_STREAM(s)
Stream::Stream ( switch_stream_handle_t sp)

Definition at line 548 of file switch_cpp.cpp.

References mine, and stream_p.

549 {
550  stream_p = sp;
551  mine = 0;
552 }
int mine
Definition: switch_cpp.h:147
switch_stream_handle_t * stream_p
Definition: switch_cpp.h:146
Stream::~Stream ( )
virtual

Definition at line 555 of file switch_cpp.cpp.

References switch_stream_handle::data, mine, mystream, and switch_safe_free.

556 {
557  if (mine) {
559  }
560 }
switch_stream_handle_t mystream
Definition: switch_cpp.h:145
int mine
Definition: switch_cpp.h:147
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:789
Stream::Stream ( void  )
Stream::Stream ( switch_stream_handle_t )
virtual Stream::~Stream ( )
virtual

Member Function Documentation

const char * Stream::get_data ( void  )

Definition at line 593 of file switch_cpp.cpp.

References this_check.

594 {
595  this_check("");
596 
597  return stream_p ? (const char *)stream_p->data : NULL;
598 }
#define this_check(x)
Definition: switch_cpp.h:12
switch_stream_handle_t * stream_p
Definition: switch_cpp.h:146
const char* Stream::get_data ( void  )
void Stream::raw_write ( const char *  data,
int  len 
)

Definition at line 587 of file switch_cpp.cpp.

References this_check_void.

588 {
589  this_check_void();
590  stream_p->raw_write_function(stream_p, (uint8_t *)data, len);
591 }
switch_stream_handle_raw_write_function_t raw_write_function
switch_stream_handle_t * stream_p
Definition: switch_cpp.h:146
#define this_check_void()
Definition: switch_cpp.h:13
void Stream::raw_write ( const char *  data,
int  len 
)
const char* Stream::read ( int *  len)
const char * Stream::read ( int *  len)

Definition at line 563 of file switch_cpp.cpp.

References this_check.

564 {
565  uint8_t *buff;
566 
567  this_check(NULL);
568 
569  if (!stream_p->read_function) return NULL;
570 
571  buff = stream_p->read_function(stream_p, len);
572 
573  if (!buff || *len <= 0) {
574  *len = 0;
575  return NULL;
576  }
577 
578  return (const char *)buff;
579 }
#define this_check(x)
Definition: switch_cpp.h:12
switch_stream_handle_t * stream_p
Definition: switch_cpp.h:146
switch_stream_handle_read_function_t read_function
void Stream::write ( const char *  data)
void Stream::write ( const char *  data)

Definition at line 581 of file switch_cpp.cpp.

References this_check_void.

582 {
583  this_check_void();
584  stream_p->write_function(stream_p, "%s", data);
585 }
switch_stream_handle_t * stream_p
Definition: switch_cpp.h:146
#define this_check_void()
Definition: switch_cpp.h:13
switch_stream_handle_write_function_t write_function

Field Documentation

int Stream::mine
protected

Definition at line 147 of file switch_cpp.h.

Referenced by Stream(), and ~Stream().

switch_stream_handle_t Stream::mystream
protected

Definition at line 145 of file switch_cpp.h.

Referenced by Stream(), and ~Stream().

switch_stream_handle_t * Stream::stream_p
protected

Definition at line 146 of file switch_cpp.h.

Referenced by Stream().


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