RTS API Documentation  1.10.11
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)
 

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() [1/2]

Stream::Stream ( void  )

Definition at line 560 of file switch_cpp.cpp.

References SWITCH_STANDARD_STREAM.

561 {
563  stream_p = &mystream;
564  mine = 1;
565 }
switch_stream_handle_t mystream
Definition: switch_cpp.h:145
switch_stream_handle_t * stream_p
Definition: switch_cpp.h:146
int mine
Definition: switch_cpp.h:147
#define SWITCH_STANDARD_STREAM(s)

◆ Stream() [2/2]

Stream::Stream ( switch_stream_handle_t sp)

Definition at line 567 of file switch_cpp.cpp.

References SWITCH_DECLARE_CONSTRUCTOR, and switch_safe_free.

568 {
569  stream_p = sp;
570  mine = 0;
571 }
switch_stream_handle_t * stream_p
Definition: switch_cpp.h:146
int mine
Definition: switch_cpp.h:147

◆ ~ Stream()

virtual Stream::~ Stream ( )
virtual

Member Function Documentation

◆ get_data()

const char * Stream::get_data ( void  )

Definition at line 612 of file switch_cpp.cpp.

References this_check.

613 {
614  this_check("");
615 
616  return stream_p ? (const char *)stream_p->data : NULL;
617 }
#define this_check(x)
Definition: switch_cpp.h:12
switch_stream_handle_t * stream_p
Definition: switch_cpp.h:146

◆ raw_write()

void Stream::raw_write ( const char *  data,
int  len 
)

Definition at line 606 of file switch_cpp.cpp.

References this_check_void.

607 {
608  this_check_void();
609  stream_p->raw_write_function(stream_p, (uint8_t *)data, len);
610 }
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

◆ read()

const char * Stream::read ( int *  len)

Definition at line 582 of file switch_cpp.cpp.

References this_check.

583 {
584  uint8_t *buff;
585 
586  this_check(NULL);
587 
588  if (!stream_p->read_function) return NULL;
589 
590  buff = stream_p->read_function(stream_p, len);
591 
592  if (!buff || *len <= 0) {
593  *len = 0;
594  return NULL;
595  }
596 
597  return (const char *)buff;
598 }
#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

◆ write()

void Stream::write ( const char *  data)

Definition at line 600 of file switch_cpp.cpp.

References this_check_void.

601 {
602  this_check_void();
603  stream_p->write_function(stream_p, "%s", data);
604 }
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

◆ mine

int Stream::mine
protected

Definition at line 147 of file switch_cpp.h.

◆ mystream

switch_stream_handle_t Stream::mystream
protected

Definition at line 145 of file switch_cpp.h.

◆ stream_p

switch_stream_handle_t* Stream::stream_p
protected

Definition at line 146 of file switch_cpp.h.


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