Changeset 591 for trunk/src/core


Ignore:
Timestamp:
Feb 25, 2007, 8:44:23 PM (18 years ago)
Author:
dkearney
Message:

Added putFile capability to octave, matlab, fortran, perl bindings
Adjusted the core putFile function and all put functions to accept unsigned ints
added enum flags for binary and text file for the putFile function in c/c++

Location:
trunk/src/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/RpLibrary.cc

    r589 r591  
    13871387                    std::string value,
    13881388                    std::string id,
    1389                     int append,
    1390                     int translateFlag)
     1389                    unsigned int append,
     1390                    unsigned int translateFlag)
    13911391{
    13921392    scew_element* retNode = NULL;
     
    14301430
    14311431RpLibrary&
    1432 RpLibrary::put ( std::string path, double value, std::string id, int append )
     1432RpLibrary::put (    std::string path,
     1433                    double value,
     1434                    std::string id,
     1435                    unsigned int append )
    14331436{
    14341437    std::stringstream valStr;
     
    14531456
    14541457RpLibrary&
    1455 RpLibrary::put ( std::string path, RpLibrary* value, std::string id, int append )
     1458RpLibrary::put (    std::string path,
     1459                    RpLibrary* value,
     1460                    std::string id,
     1461                    unsigned int append )
    14561462{
    14571463    scew_element* retNode   = NULL;
     
    15271533                    const char* bytes,
    15281534                    int nbytes,
    1529                     int append  )
     1535                    unsigned int append  )
    15301536{
    15311537    scew_element* retNode = NULL;
     
    15641570
    15651571/**********************************************************************/
    1566 // METHOD: putData()
     1572// METHOD: putFile()
    15671573/// Put data from a file into the xml.
    15681574/**
     
    15741580RpLibrary::putFile (std::string path,
    15751581                    std::string fileName,
    1576                     bool binary,
    1577                     int append  )
     1582                    unsigned int fileType,
     1583                    unsigned int append  )
    15781584{
    15791585    scew_element* retNode = NULL;
     
    15951601            if ( (contents = scew_element_contents(retNode)) ) {
    15961602                buf.append(contents);
    1597                 if (binary == true) {
     1603                if (fileType == RPLIB_BINARY) {
    15981604                    // base64 decode and un-gzip the data
    15991605                    buf.decode();
     
    16051611        buf += fileBuf;
    16061612
    1607         if (binary == true) {
     1613        if (fileType == RPLIB_BINARY) {
    16081614            // gzip and base64 encode the data
    16091615            buf.encode();
    16101616        }
    16111617
    1612         bytesWritten = (unsigned int) buf.size();
     1618        bytesWritten = buf.size();
    16131619        scew_element_set_contents_binary(retNode,buf.bytes(),&bytesWritten);
     1620
     1621        if (bytesWritten == buf.size()) {
     1622            // error writing data to xml
     1623        }
    16141624
    16151625    }
  • trunk/src/core/RpLibrary.h

    r589 r591  
    2020    RPLIB_NO_TRANSLATE  = 0,
    2121    RPLIB_TRANSLATE     = 1,
     22    RPLIB_TEXT          = 0,
     23    RPLIB_BINARY        = 1,
    2224};
    2325
     
    112114                            std::string value,
    113115                            std::string id = "",
    114                             int append = RPLIB_OVERWRITE,
    115                             int translateFlag = RPLIB_TRANSLATE   );
     116                            unsigned int append = RPLIB_OVERWRITE,
     117                            unsigned int translateFlag = RPLIB_TRANSLATE   );
    116118
    117119        RpLibrary& put (    std::string path,
    118120                            double value,
    119121                            std::string id = "",
    120                             int append = RPLIB_OVERWRITE    );
     122                            unsigned int append = RPLIB_OVERWRITE    );
    121123
    122124        RpLibrary& put (    std::string path,
    123125                            RpLibrary* value,
    124126                            std::string id = "",
    125                             int append = RPLIB_OVERWRITE    );
     127                            unsigned int append = RPLIB_OVERWRITE    );
    126128
    127129        RpLibrary& putData( std::string path,
    128130                            const char* bytes,
    129131                            int nbytes,
    130                             int append = RPLIB_OVERWRITE    );
     132                            unsigned int append = RPLIB_OVERWRITE    );
    131133
    132134        RpLibrary& putFile( std::string path,
    133135                            std::string fileName,
    134                             bool binary,
    135                             int append = RPLIB_OVERWRITE    );
     136                            unsigned int fileType = RPLIB_BINARY,
     137                            unsigned int append = RPLIB_OVERWRITE    );
    136138
    137139        RpLibrary* remove (std::string path = "");
Note: See TracChangeset for help on using the changeset viewer.