Changeset 591


Ignore:
Timestamp:
Feb 25, 2007 8:44:23 PM (17 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
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/perl/Rappture.xs

    r517 r591  
    5656        CODE:
    5757                THIS->put(path,value,"",append);
    58                
     58
     59void
     60RpLibrary::putFile( path, fileName, fileType, append )
     61char *path
     62char *fileName
     63int fileType
     64int append
     65        CODE:
     66                THIS->putFile(path,fileName,fileType,append);
     67
    5968void
    6069RpLibrary::result()
  • 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 = "");
  • trunk/src/fortran/RpLibraryFInterface.cc

    r496 r591  
    55 * ======================================================================
    66 *  AUTHOR:  Derrick Kearney, Purdue University
    7  *  Copyright (c) 2004-2005  Purdue Research Foundation
     7 *  Copyright (c) 2004-2007  Purdue Research Foundation
    88 *
    99 *  See the file "license.terms" for information on usage and
     
    670670
    671671}
     672
     673
     674/**********************************************************************/
     675// FUNCTION: rp_lib_put_data()
     676/// Put string into Rappture Library Object at location 'path'.
     677/**
     678 */
     679void rp_lib_put_data( int* handle,
     680                        char* path,
     681                        char* bytes,
     682                        int* nbytes,
     683                        int* append,
     684                        int path_len,
     685                        int bytes_len
     686                      )
     687{
     688    std::string inPath = "";
     689    RpLibrary* lib = NULL;
     690
     691    inPath = null_terminate_str(path,path_len);
     692
     693    if ((handle) && (*handle != 0)) {
     694        lib = getObject_Lib(*handle);
     695
     696        if (lib) {
     697            lib->putData(inPath,bytes,*nbytes,*append);
     698        }
     699    }
     700
     701    return;
     702
     703}
     704
     705
     706/**********************************************************************/
     707// FUNCTION: rp_lib_put_file()
     708/// Put string into Rappture Library Object at location 'path'.
     709/**
     710 */
     711void rp_lib_put_file( int* handle,
     712                        char* path,
     713                        char* fileName,
     714                        int* fileType,
     715                        int* append,
     716                        int path_len,
     717                        int fileName_len
     718                      )
     719{
     720    std::string inPath = "";
     721    std::string inFileName = "";
     722    RpLibrary* lib = NULL;
     723
     724    inPath = null_terminate_str(path,path_len);
     725    inFileName = null_terminate_str(fileName,fileName_len);
     726
     727    if ((handle) && (*handle != 0)) {
     728        lib = getObject_Lib(*handle);
     729
     730        if (lib) {
     731            lib->putFile(inPath,inFileName,*fileType,*append);
     732        }
     733    }
     734
     735    return;
     736
     737}
     738
    672739
    673740//void rp_lib_put_obj( int* handle,
  • trunk/src/fortran/RpLibraryFInterface.h

    r554 r591  
    55 * ======================================================================
    66 *  AUTHOR:  Derrick S. Kearney, Purdue University
    7  *  Copyright (c) 2004-2005  Purdue Research Foundation
     7 *  Copyright (c) 2004-2007  Purdue Research Foundation
    88 *
    99 *  See the file "license.terms" for information on usage and
     
    9595                            int id_len );
    9696
     97void rp_lib_put_data (      int* handle,
     98                            char* path,
     99                            char* bytes,
     100                            int* nbytes,
     101                            int* append,
     102                            int path_len,
     103                            int bytes_len );
     104
     105void rp_lib_put_file (      int* handle,
     106                            char* path,
     107                            char* fileName,
     108                            int* fileType,
     109                            int* append,
     110                            int path_len,
     111                            int fileName_len );
     112
    97113/*
    98114 * rp_lib_put_obj still needs to be written
  • trunk/src/fortran/RpLibraryFStubs.c

    r496 r591  
    55 * ======================================================================
    66 *  AUTHOR:  Derrick Kearney, Purdue University
    7  *  Copyright (c) 2004-2005  Purdue Research Foundation
     7 *  Copyright (c) 2004-2007  Purdue Research Foundation
    88 *
    99 *  See the file "license.terms" for information on usage and
     
    348348                        int value_len ) {
    349349
    350     return rp_lib_put_str(handle,path,value,append,path_len,value_len);
     350    rp_lib_put_str(handle,path,value,append,path_len,value_len);
     351    return;
    351352}
    352353
     
    359360                        int value_len ) {
    360361
    361     return rp_lib_put_str(handle,path,value,append,path_len,value_len);
     362    rp_lib_put_str(handle,path,value,append,path_len,value_len);
     363    return;
    362364}
    363365
     
    370372                        int value_len ) {
    371373
    372     return rp_lib_put_str(handle,path,value,append,path_len,value_len);
     374    rp_lib_put_str(handle,path,value,append,path_len,value_len);
     375    return;
    373376}
    374377
     
    383386                        int id_len ) {
    384387
    385     return rp_lib_put_id_str( handle, path, value,id,append,
    386                               path_len,value_len,id_len);
     388    rp_lib_put_id_str(handle,path,value,id,append,path_len,value_len,id_len);
     389    return;
    387390}
    388391
     
    397400                        int id_len ) {
    398401
    399     return rp_lib_put_id_str( handle, path, value,id,append,
    400                               path_len,value_len,id_len);
     402    rp_lib_put_id_str(handle,path,value,id,append,path_len,value_len,id_len);
     403    return;
    401404}
    402405
     
    411414                        int id_len ) {
    412415
    413     return rp_lib_put_id_str( handle, path, value,id,append,
    414                               path_len,value_len,id_len);
     416    rp_lib_put_id_str(handle,path,value,id,append,path_len,value_len,id_len);
     417    return;
     418}
     419
     420void
     421rp_lib_put_data_ (      int* handle,
     422                        char* path,
     423                        char* bytes,
     424                        int* nbytes,
     425                        int* append,
     426                        int path_len,
     427                        int bytes_len ) {
     428
     429    rp_lib_put_data(handle,path,bytes,nbytes,append,path_len,bytes_len);
     430    return;
     431}
     432
     433void
     434rp_lib_put_data__ (     int* handle,
     435                        char* path,
     436                        char* bytes,
     437                        int* nbytes,
     438                        int* append,
     439                        int path_len,
     440                        int bytes_len ) {
     441
     442    rp_lib_put_data(handle,path,bytes,nbytes,append,path_len,bytes_len);
     443    return;
     444}
     445
     446void
     447RP_LIB_PUT_DATA (       int* handle,
     448                        char* path,
     449                        char* bytes,
     450                        int* nbytes,
     451                        int* append,
     452                        int path_len,
     453                        int bytes_len ) {
     454
     455    rp_lib_put_data(handle,path,bytes,nbytes,append,path_len,bytes_len);
     456    return;
     457}
     458
     459void
     460rp_lib_put_file_ (      int* handle,
     461                        char* path,
     462                        char* fileName,
     463                        int* fileType,
     464                        int* append,
     465                        int path_len,
     466                        int fileName_len ) {
     467
     468    rp_lib_put_file(handle,path,fileName,fileType,append,path_len,fileName_len);
     469    return;
     470}
     471
     472void
     473rp_lib_put_file__ (     int* handle,
     474                        char* path,
     475                        char* fileName,
     476                        int* fileType,
     477                        int* append,
     478                        int path_len,
     479                        int fileName_len ) {
     480
     481    rp_lib_put_file(handle,path,fileName,fileType,append,path_len,fileName_len);
     482    return;
     483}
     484
     485void
     486RP_LIB_PUT_FILE (       int* handle,
     487                        char* path,
     488                        char* fileName,
     489                        int* fileType,
     490                        int* append,
     491                        int path_len,
     492                        int fileName_len ) {
     493
     494    rp_lib_put_file(handle,path,fileName,fileType,append,path_len,fileName_len);
     495    return;
    415496}
    416497
  • trunk/src/fortran/RpLibraryFStubs.h

    r511 r591  
    55 * ======================================================================
    66 *  AUTHOR:  Derrick Kearney, Purdue University
    7  *  Copyright (c) 2004-2005  Purdue Research Foundation
     7 *  Copyright (c) 2004-2007  Purdue Research Foundation
    88 *
    99 *  See the file "license.terms" for information on usage and
     
    9898                            int id_len );
    9999
     100void rp_lib_put_data_ (     int* handle,
     101                            char* path,
     102                            char* bytes,
     103                            int* nbytes,
     104                            int* append,
     105                            int path_len,
     106                            int bytes_len );
     107
     108void rp_lib_put_file_ (     int* handle,
     109                            char* path,
     110                            char* fileName,
     111                            int* fileType,
     112                            int* append,
     113                            int path_len,
     114                            int fileName_len );
     115
     116/*
    100117void rp_lib_put_obj_ (      int* handle,
    101118                            char* path,
     
    111128                            int path_len,
    112129                            int id_len );
     130*/
    113131
    114132int rp_lib_remove_ (        int* handle,
     
    221239                            int id_len );
    222240
     241void rp_lib_put_data__ (    int* handle,
     242                            char* path,
     243                            char* bytes,
     244                            int* nbytes,
     245                            int* append,
     246                            int path_len,
     247                            int bytes_len );
     248
     249void rp_lib_put_file__ (    int* handle,
     250                            char* path,
     251                            char* fileName,
     252                            int* fileType,
     253                            int* append,
     254                            int path_len,
     255                            int fileName_len );
     256
     257/*
    223258void rp_lib_put_obj__ (     int* handle,
    224259                            char* path,
     
    234269                            int path_len,
    235270                            int id_len );
     271*/
    236272
    237273int rp_lib_remove__ (       int* handle,
     
    345381                            int id_len );
    346382
     383void RP_LIB_PUT_DATA (      int* handle,
     384                            char* path,
     385                            char* bytes,
     386                            int* nbytes,
     387                            int* append,
     388                            int path_len,
     389                            int bytes_len );
     390
     391void RP_LIB_PUT_FILE (      int* handle,
     392                            char* path,
     393                            char* fileName,
     394                            int* fileType,
     395                            int* append,
     396                            int path_len,
     397                            int fileName_len );
     398/*
    347399void RP_LIB_PUT_OBJ (       int* handle,
    348400                            char* path,
     
    358410                            int path_len,
    359411                            int id_len );
     412*/
    360413
    361414int RP_LIB_REMOVE (         int* handle,
     
    391444/**********************************************************/
    392445
    393 #ifdef __cplusplus 
     446#ifdef __cplusplus
    394447    }
    395448#endif
  • trunk/src/matlab/Makefile.in

    r569 r591  
    5959                        rpLibPutString.mexglx \
    6060                        rpLibPutDouble.mexglx \
     61                        rpLibPutFile.mexglx \
    6162                        rpLibNodeComp.mexglx \
    6263                        rpLibNodeType.mexglx \
     
    118119rpLibPutDouble.mexglx:
    119120        $(MEX) rpLibPutDouble.cc          $(MATLAB_COMP_ARGS)
     121rpLibPutFile.mexglx:
     122        $(MEX) rpLibPutFile.cc            $(MATLAB_COMP_ARGS)
    120123rpLibNodeComp.mexglx:
    121124        $(MEX) rpLibNodeComp.cc           $(MATLAB_COMP_ARGS)
  • trunk/src/octave/Makefile.in

    r569 r591  
    5656                        rpLibPutDouble.oct \
    5757                        rpLibPutSingle.oct \
     58                        rpLibPutFile.oct \
    5859                        rpLibResult.oct \
    5960                        rpLibXml.oct \
     
    106107rpLibPutSingle.oct:
    107108        $(OCT) rpLibPutString.cc          $(OCTAVE_COMP_ARGS)
     109rpLibPutFile.oct:
     110        $(OCT) rpLibPutFile.cc            $(OCTAVE_COMP_ARGS)
    108111rpLibResult.oct:
    109112        $(OCT) rpLibResult.cc             $(OCTAVE_COMP_ARGS)
Note: See TracChangeset for help on using the changeset viewer.