Changeset 25:77da156bca86 in xplra for src/client/c/hu


Ignore:
Timestamp:
02/07/13 16:45:59 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Implemented the set operations

Location:
src/client/c/hu/varadiistvan/xplra
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/client/c/hu/varadiistvan/xplra/xplra.cc

    r24 r25  
    505505//------------------------------------------------------------------------------
    506506
     507extern "C" int xplra_set_int(int connectionID, const char* name, int value)
     508{
     509    Connection* connection = Slot::getConnection(connectionID);
     510    if (connection==0) return 0;
     511    try {
     512        connection->setInt(name, value);
     513        return 0;
     514    } catch (...) {
     515        connection->handleException();
     516        return -1;
     517    }
     518}
     519
     520//------------------------------------------------------------------------------
     521
     522extern "C" int xplra_set_float(int connectionID, const char* name, float value)
     523{
     524    Connection* connection = Slot::getConnection(connectionID);
     525    if (connection==0) return 0;
     526    try {
     527        connection->setFloat(name, value);
     528        return 0;
     529    } catch (...) {
     530        connection->handleException();
     531        return -1;
     532    }
     533}
     534
     535//------------------------------------------------------------------------------
     536
     537extern "C" int xplra_set_double(int connectionID, const char* name,
     538                                double value)
     539{
     540    Connection* connection = Slot::getConnection(connectionID);
     541    if (connection==0) return 0;
     542    try {
     543        connection->setDouble(name, value);
     544        return 0;
     545    } catch (...) {
     546        connection->handleException();
     547        return -1;
     548    }
     549}
     550
     551/*----------------------------------------------------------------------------*/
     552
     553extern "C" int xplra_set_float_array(int connectionID, const char* name,
     554                                     const float* values,
     555                                     size_t length, size_t offset)
     556{
     557    Connection* connection = Slot::getConnection(connectionID);
     558    if (connection==0) return 0;
     559    try {
     560        connection->setFloatArray(name, values, length, offset);
     561        return 0;
     562    } catch (...) {
     563        connection->handleException();
     564        return -1;
     565    }
     566}
     567
     568/*----------------------------------------------------------------------------*/
     569
     570extern "C" int xplra_set_int_array(int connectionID, const char* name,
     571                                   const int32_t* values,
     572                                   size_t length, size_t offset)
     573{
     574    Connection* connection = Slot::getConnection(connectionID);
     575    if (connection==0) return 0;
     576    try {
     577        connection->setIntArray(name, values, length, offset);
     578        return 0;
     579    } catch (...) {
     580        connection->handleException();
     581        return -1;
     582    }
     583}
     584
     585/*----------------------------------------------------------------------------*/
     586
     587extern "C" int xplra_set_byte_array(int connectionID, const char* name,
     588                                    const void* values,
     589                                    size_t length, size_t offset)
     590{
     591    Connection* connection = Slot::getConnection(connectionID);
     592    if (connection==0) return 0;
     593    try {
     594        connection->setByteArray(name, reinterpret_cast<const uint8_t*>(values),
     595                                 length, offset);
     596        return 0;
     597    } catch (...) {
     598        connection->handleException();
     599        return -1;
     600    }
     601}
     602
     603/*----------------------------------------------------------------------------*/
     604
     605extern "C" int xplra_set_string(int connectionID, const char* name,
     606                                const char* value,
     607                                size_t length, size_t offset)
     608{
     609    Connection* connection = Slot::getConnection(connectionID);
     610    if (connection==0) return 0;
     611    try {
     612        connection->setString(name, value, length, offset);
     613        return 0;
     614    } catch (...) {
     615        connection->handleException();
     616        return -1;
     617    }
     618}
     619
     620//------------------------------------------------------------------------------
     621
    507622extern "C" int xplra_disconnect(int connectionID)
    508623{
  • src/client/c/hu/varadiistvan/xplra/xplra.h

    r24 r25  
    245245
    246246/**
     247 * Set the integer dataref with the given name to the given value.
     248 *
     249 * @return 0 on success, -1 on error.
     250 */
     251int xplra_set_int(int connectionID, const char* name, int value);
     252
     253/*----------------------------------------------------------------------------*/
     254
     255/**
     256 * Set the float dataref with the given name to the given value.
     257 *
     258 * @return 0 on success, -1 on error.
     259 */
     260int xplra_set_float(int connectionID, const char* name, float value);
     261
     262/*----------------------------------------------------------------------------*/
     263
     264/**
     265 * Set the double dataref with the given name to the given value.
     266 *
     267 * @return 0 on success, -1 on error.
     268 */
     269int xplra_set_double(int connectionID, const char* name, double value);
     270
     271/*----------------------------------------------------------------------------*/
     272
     273/**
     274 * Set the array of float values with the given name from the given
     275 * buffer.
     276 *
     277 * @return 0 on success, -1 on error.
     278 */
     279int xplra_set_float_array(int connectionID, const char* name,
     280                          const float* values, size_t length, size_t offset);
     281
     282/*----------------------------------------------------------------------------*/
     283
     284/**
     285 * Set the array of integer values with the given name from the given
     286 * buffer.
     287 *
     288 * @return 0 on success, -1 on error.
     289 */
     290int xplra_set_int_array(int connectionID, const char* name,
     291                        const int32_t* values, size_t length, size_t offset);
     292
     293/*----------------------------------------------------------------------------*/
     294
     295/**
     296 * Set the array of byte values with the given name from the given
     297 * buffer.
     298 *
     299 * @return 0 on success, -1 on error.
     300 */
     301int xplra_set_byte_array(int connectionID, const char* name,
     302                         const void* values, size_t length, size_t offset);
     303
     304/*----------------------------------------------------------------------------*/
     305
     306/**
     307 * Set the array of byte values with the given name from the given
     308 * string. The string will be padded with 0 if it has a length less
     309 * than the given length.
     310 *
     311 * @return 0 on success, -1 on error.
     312 */
     313int xplra_set_string(int connectionID, const char* name,
     314                     const char* value, size_t length, size_t offset);
     315
     316/*----------------------------------------------------------------------------*/
     317
     318/**
    247319 * Destroy the connection with the given ID.
    248320 *
Note: See TracChangeset for help on using the changeset viewer.