Changeset 1325 for trunk/src/core


Ignore:
Timestamp:
Mar 14, 2009, 4:20:03 PM (16 years ago)
Author:
gah
Message:

Clean up of warnings, outcomes

Location:
trunk/src/core
Files:
4 edited

Legend:

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

    r1092 r1325  
    210210
    211211DXWriter&
    212 DXWriter::write(FILE *stream)
    213 {
    214     SimpleCharBuffer *dxfile = NULL;
    215 
    216     if (stream == NULL) {
    217         fprintf(stderr,"stream is NULL, cannot write to NULL file inside DXWriter::write\n");
    218         return *this;
    219     }
    220 
    221     dxfile = new SimpleCharBuffer();
    222 
     212DXWriter::write(FILE *f)
     213{
     214    if (f == NULL) {
     215        fprintf(stderr,"FILE is NULL, cannot write to NULL file inside DXWriter::write\n");
     216        return *this;
     217    }
     218    SimpleCharBuffer dxfile;
    223219    _writeDxToBuffer(dxfile);
    224     fwrite((const void*)(dxfile->bytes()),1,dxfile->size(),stream);
    225 
    226     delete dxfile;
    227 
     220    ssize_t nWritten;
     221    nWritten = fwrite(dxfile.bytes(), 1, dxfile.size(), f);
     222    assert(nWritten == (ssize_t)dxfile.size());
    228223    return *this;
    229224}
     
    249244DXWriter::write(char *str)
    250245{
    251     SimpleCharBuffer *dxfile = NULL;
    252     int sz = 0;
    253 
    254     dxfile = new SimpleCharBuffer();
     246    SimpleCharBuffer dxfile;
     247    int sz;
    255248
    256249    _writeDxToBuffer(dxfile);
    257     sz = dxfile->size();
     250    sz = dxfile.size();
    258251    str = new char[sz+1];
    259     memcpy(str,dxfile->bytes(),sz);
     252    memcpy(str, dxfile.bytes(), sz);
    260253    str[sz] = '\0';
    261 
    262     delete dxfile;
    263 
    264254    return *this;
    265255}
     
    273263
    274264DXWriter&
    275 DXWriter::_writeDxToBuffer(SimpleCharBuffer *dxfile)
     265DXWriter::_writeDxToBuffer(SimpleCharBuffer &dxfile)
    276266{
    277267    char b[80];
     
    281271    // because we know there are at least
    282272    // 400 characters in even our smallest dx file.
    283     dxfile->set(512);
    284 
    285     dxfile->append("<ODX>object 1 class gridpositions counts",40);
     273    dxfile.set(512);
     274
     275    dxfile.append("<ODX>object 1 class gridpositions counts",40);
    286276    for (size_t i=0; i < _rank; i++) {
    287277        sprintf(b, " %10lu", (unsigned long)_positions[i]);
    288         dxfile->append(b,11);
    289     }
    290 
    291     dxfile->append("\norigin");
     278        dxfile.append(b,11);
     279    }
     280
     281    dxfile.append("\norigin");
    292282    for (size_t i=0; i < _rank; i++) {
    293283        sprintf(b, " %10g",_origin[i]);
    294         dxfile->append(b,11);
     284        dxfile.append(b,11);
    295285    }
    296286
    297287    for (size_t row=0; row < _rank; row++) {
    298         dxfile->append("\ndelta");
     288        dxfile.append("\ndelta");
    299289        for (size_t col=0; col < _rank; col++) {
    300290            sprintf(b, " %10g",_delta[(_rank*row)+col]);
    301             dxfile->append(b,11);
     291            dxfile.append(b,11);
    302292        }
    303293    }
    304294
    305     dxfile->append("\nobject 2 class gridconnections counts", 38);
     295    dxfile.append("\nobject 2 class gridconnections counts", 38);
    306296    for (size_t i=0; i < _rank; i++) {
    307297        sprintf(b, " %10lu",(unsigned long)_positions[i]);
    308         dxfile->append(b,11);
    309     }
    310 
    311     dxfile->append("\nattribute \"element type\" string \"cubes\"\n",41);
    312     dxfile->append("attribute \"ref\" string \"positions\"\n",35);
     298        dxfile.append(b,11);
     299    }
     300
     301    dxfile.append("\nattribute \"element type\" string \"cubes\"\n",41);
     302    dxfile.append("attribute \"ref\" string \"positions\"\n",35);
    313303
    314304    sprintf(b,"object 3 class array type float rank 0 items %lu data follows\n",
    315305        (unsigned long)_dataBuf.nmemb());
    316     dxfile->append(b);
     306    dxfile.append(b);
    317307
    318308    _dataBuf.seek(0,SEEK_SET);
     
    327317        // only that it has 10 sigdigs, so we cannot tell
    328318        // append the size of the data
    329         // dxfile->append(b,15);
    330         dxfile->append(b);
    331     }
    332 
    333     dxfile->append("attribute \"dep\" string \"positions\"\n",35);
    334     dxfile->append("object \"density\" class field\n",29);
    335     dxfile->append("component \"positions\" value 1\n",30);
    336     dxfile->append("component \"connections\" value 2\n",32);
    337     dxfile->append("component \"data\" value 3\n",25);
     319        // dxfile.append(b,15);
     320        dxfile.append(b);
     321    }
     322
     323    dxfile.append("attribute \"dep\" string \"positions\"\n",35);
     324    dxfile.append("object \"density\" class field\n",29);
     325    dxfile.append("component \"positions\" value 1\n",30);
     326    dxfile.append("component \"connections\" value 2\n",32);
     327    dxfile.append("component \"data\" value 3\n",25);
    338328
    339329    return *this;
  • trunk/src/core/RpDXWriter.h

    r1109 r1325  
     1
    12/*
    23 * ----------------------------------------------------------------------
     
    5859    double* _origin;       // array holding coord of origin
    5960
    60     DXWriter& _writeDxToBuffer(SimpleCharBuffer *dxfile);
     61    DXWriter& _writeDxToBuffer(SimpleCharBuffer &dxfile);
    6162};
    6263
  • trunk/src/core/RpOutcome.cc

    r1051 r1325  
    6363
    6464Outcome&
    65 Outcome::AddError(const char* format, ...)
     65Outcome::addError(const char* format, ...)
    6666{
    6767    char stackSpace[1024];
     
    138138 *  Query the error remark from an outcome.
    139139 */
    140 std::string
     140const char *
    141141Outcome::remark() const
    142142{
    143     if (!_remarkPtr.isNull()) {
    144         return _remarkPtr->data();
    145     }
    146     return "";
     143    return (!_remarkPtr.isNull()) ? _remarkPtr->data() : "";
    147144}
    148145
     
    164161 *  Query the context stack from an outcome.
    165162 */
    166 std::string
     163
     164const char *
    167165Outcome::context() const
    168166{
    169     if (!_contextPtr.isNull()) {
    170         return _contextPtr->data();
    171     }
    172     return "";
     167    return (!_contextPtr.isNull()) ? _contextPtr->data() : "";
    173168}
  • trunk/src/core/RpOutcome.h

    r1023 r1325  
    3131    virtual ~Outcome();
    3232
    33     Outcome& AddError(const char* format, ...);
     33    Outcome& addError(const char* format, ...);
    3434    virtual Outcome& error(const char* errmsg, int status=1);
    3535    virtual Outcome& clear();
     
    3939    virtual Outcome& operator&=(Outcome status);  // pass-by-value to avoid temp
    4040
    41     virtual std::string remark() const;
     41    virtual const char *remark() const;
    4242    virtual Outcome& addContext(const char *rem);
    43     virtual std::string context() const;
     43    virtual const char *context() const;
    4444
    4545private:
Note: See TracChangeset for help on using the changeset viewer.