scim::Transaction Class Reference
SocketCommunication

This class is used to pack up many data and commands into one package and send them via socket. More...

`#include <scim_transaction.h>`

## Public Member Functions

| Transaction (size_t bufsize=512)
| Constructor.
| ~Transaction ()
| Destructor.
bool | valid () const
| Check if the transaction is valid.
size_t | get_size () const
| Get the size of this transaction.
bool | write_to_socket (const Socket &socket, uint32 signature=0) const
| Write the transaction to a socket.
bool | read_from_socket (const Socket &socket, int timeout=-1)
| Read a transaction from a socket.
bool | write_to_buffer (void *buf, size_t bufsize) const
| Write the transaction into a buffer.
bool | read_from_buffer (const void *buf, size_t bufsize)
| Read a transaction from a buffer.
void | put_command (int cmd)
| Store a command into this transaction.
void | put_data (uint32 val)
| Store a uint32 value into this transaction.
void | put_data (const String &str)
| Store a String object into this transaction.
void | put_data (const WideString &str)
| Store a WideString object into this transaction.
void | put_data (const KeyEvent &key)
| Store a KeyEvent object into this transaction.
void | put_data (const AttributeList &attrs)
| Store an AttributeList object into this transaction.
void | put_data (const Property &property)
| Store a Property object into this transaction.
void | put_data (const PropertyList &properties)
| Store a PropertyList object into this transaction.
void | put_data (const LookupTable &table)
| Store a LookupTable object into this transaction.
void | put_data (const std::vector< uint32 > &vec)
| Store a std::vector<uint32> object into this transaction.
void | put_data (const std::vector< String > &vec)
| Store a std::vector<String> object into this transaction.
void | put_data (const std::vector< WideString > &vec)
| Store a std::vector<WideString> object into this transaction.
void | put_data (const char *raw, size_t bufsize)
| Store a raw buffer into this transaction.
void | put_data (const Transaction &trans)
| Store another Transaction object into this transaction.
TransactionDataType | get_data_type () const
| Get the type of the data at current read position.
bool | get_command (int &cmd)
| Get a command from current read position.
bool | get_data (uint32 &val)
| Get an uint32 value from current read position.
bool | get_data (String &str)
| Get a String from current read position.
bool | get_data (WideString &str)
| Get a WideString from current read position.
bool | get_data (KeyEvent &key)
| Get a KeyEvent from current read position.
bool | get_data (AttributeList &attrs)
| Get an AttributeList from current read position.
bool | get_data (Property &property)
| Get a Property from current read position.
bool | get_data (PropertyList &properties)
| Get a PropertyList from current read position.
bool | get_data (CommonLookupTable &table)
| Get a CommonLookupTable from current read position.
bool | get_data (std::vector< uint32 > &vec)
| Get a std::vector<uint32> from current read position.
bool | get_data (std::vector< String > &vec)
| Get a std::vector<String> from current read position.
bool | get_data (std::vector< WideString > &vec)
| Get a std::vector<WideString> from current read position.
bool | get_data (char **raw, size_t &bufsize)
| Get a raw buffer from current read position.
bool | get_data (Transaction &trans)
| Get a Transaction object from current read position.
bool | skip_data ()
| Skip one data from current read position.
void | rewind ()
| Rewind the current read position, then the data can be read again.
void | clear ()
| Clear the transaction, all data in this transaction will be freed.

## Friends

class | TransactionReader

## Detailed Description

This class is used to pack up many data and commands into one package and send them via socket.

## Constructor & Destructor Documentation

## Transaction()

scim::Transaction::Transaction | ( | size_t | bufsize = 512 | ) |

Constructor.

Parameters

  bufsize | the initial buffer size, maybe grow afterwards.

## ~Transaction()

scim::Transaction::~Transaction | ( |  | ) |

Destructor.

## Member Function Documentation

## valid()

bool scim::Transaction::valid | ( |  | ) | const

Check if the transaction is valid.

Returns
  true if this Transaction object is valid and ready to use.

## get_size()

size_t scim::Transaction::get_size | ( |  | ) | const

Get the size of this transaction.

## write_to_socket()

bool scim::Transaction::write_to_socket | ( | const Socket & | socket,
|  | uint32 | signature = 0 ) const

Write the transaction to a socket.

Parameters

  socket | the socket to be written to.
  signature | the leading signature to be written into the socket before the transaction itself, this signature maybe missing when receive the transaction. It's useful to check the connection before receiving a transaction by reading this signature.

Returns
  true if success.

## read_from_socket()

bool scim::Transaction::read_from_socket | ( | const Socket & | socket,
|  | int | timeout = -1 )

Read a transaction from a socket.

Parameters

  socket | the socket to be read from.
  timeout | time out in millisecond (1/1000 second), -1 means infinity.

Returns
  true if success.

## write_to_buffer()

bool scim::Transaction::write_to_buffer | ( | void * | buf,
|  | size_t | bufsize ) const

Write the transaction into a buffer.

Parameters

  buf | A buffer to store the transaction data.
  bufsize | The size of this buffer.

Returns
  true if success (the buf is large enough).

## read_from_buffer()

bool scim::Transaction::read_from_buffer | ( | const void * | buf,
|  | size_t | bufsize )

Read a transaction from a buffer.

Parameters

  buf | A buffer contains the transaction.
  bufsize | The size of this buffer.

Returns
  true if success.

## put_command()

void scim::Transaction::put_command | ( | int | cmd | ) |

Store a command into this transaction.

Parameters

  cmd | the command code, like SCIM_TRANS_CMD_FOCUS_IN etc.

## put_data() [1/13]

void scim::Transaction::put_data | ( | uint32 | val | ) |

Store a uint32 value into this transaction.

## put_data() [2/13]

void scim::Transaction::put_data | ( | const String & | str | ) |

Store a String object into this transaction.

## put_data() [3/13]

void scim::Transaction::put_data | ( | const WideString & | str | ) |

Store a WideString object into this transaction.

## put_data() [4/13]

void scim::Transaction::put_data | ( | const KeyEvent & | key | ) |

Store a KeyEvent object into this transaction.

## put_data() [5/13]

void scim::Transaction::put_data | ( | const AttributeList & | attrs | ) |

Store an AttributeList object into this transaction.

## put_data() [6/13]

void scim::Transaction::put_data | ( | const Property & | property | ) |

Store a Property object into this transaction.

## put_data() [7/13]

void scim::Transaction::put_data | ( | const PropertyList & | properties | ) |

Store a PropertyList object into this transaction.

## put_data() [8/13]

void scim::Transaction::put_data | ( | const LookupTable & | table | ) |

Store a LookupTable object into this transaction.

## put_data() [9/13]

void scim::Transaction::put_data | ( | const std::vector< uint32 > & | vec | ) |

Store a std::vector<uint32> object into this transaction.

## put_data() [10/13]

void scim::Transaction::put_data | ( | const std::vector< String > & | vec | ) |

Store a std::vector<String> object into this transaction.

## put_data() [11/13]

void scim::Transaction::put_data | ( | const std::vector< WideString > & | vec | ) |

Store a std::vector<WideString> object into this transaction.

## put_data() [12/13]

void scim::Transaction::put_data | ( | const char * | raw,
|  | size_t | bufsize )

Store a raw buffer into this transaction.

## put_data() [13/13]

void scim::Transaction::put_data | ( | const Transaction & | trans | ) |

Store another Transaction object into this transaction.

## get_data_type()

TransactionDataType scim::Transaction::get_data_type | ( |  | ) | const

Get the type of the data at current read position.

Returns
  The type of the data can be read currently.

## get_command()

bool scim::Transaction::get_command | ( | int & | cmd | ) |

Get a command from current read position.

## get_data() [1/13]

bool scim::Transaction::get_data | ( | uint32 & | val | ) |

Get an uint32 value from current read position.

## get_data() [2/13]

bool scim::Transaction::get_data | ( | String & | str | ) |

Get a String from current read position.

## get_data() [3/13]

bool scim::Transaction::get_data | ( | WideString & | str | ) |

Get a WideString from current read position.

## get_data() [4/13]

bool scim::Transaction::get_data | ( | KeyEvent & | key | ) |

Get a KeyEvent from current read position.

## get_data() [5/13]

bool scim::Transaction::get_data | ( | AttributeList & | attrs | ) |

Get an AttributeList from current read position.

## get_data() [6/13]

bool scim::Transaction::get_data | ( | Property & | property | ) |

Get a Property from current read position.

## get_data() [7/13]

bool scim::Transaction::get_data | ( | PropertyList & | properties | ) |

Get a PropertyList from current read position.

## get_data() [8/13]

bool scim::Transaction::get_data | ( | CommonLookupTable & | table | ) |

Get a CommonLookupTable from current read position.

## get_data() [9/13]

bool scim::Transaction::get_data | ( | std::vector< uint32 > & | vec | ) |

Get a std::vector<uint32> from current read position.

## get_data() [10/13]

bool scim::Transaction::get_data | ( | std::vector< String > & | vec | ) |

Get a std::vector<String> from current read position.

## get_data() [11/13]

bool scim::Transaction::get_data | ( | std::vector< WideString > & | vec | ) |

Get a std::vector<WideString> from current read position.

## get_data() [12/13]

bool scim::Transaction::get_data | ( | char ** | raw,
|  | size_t & | bufsize )

Get a raw buffer from current read position.

if raw == NULL then return the bufsize and skip this data. *raw should be deleted afterwards (do not use free!).

## get_data() [13/13]

bool scim::Transaction::get_data | ( | Transaction & | trans | ) |

Get a Transaction object from current read position.

## skip_data()

bool scim::Transaction::skip_data | ( |  | ) |

Skip one data from current read position.

## rewind()

void scim::Transaction::rewind | ( |  | ) |

Rewind the current read position, then the data can be read again.

## clear()

void scim::Transaction::clear | ( |  | ) |

Clear the transaction, all data in this transaction will be freed.

## Friends And Related Symbol Documentation

## TransactionReader

friend class TransactionReader

friend

References TransactionReader.

Referenced by TransactionReader.

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

- scim_transaction.h