Ignore:
Timestamp:
Apr 16, 2012 12:14:03 PM (12 years ago)
Author:
ldelgass
Message:

Remove vrutil library. Was only used for FilePath? that already exists in
R2 library (may need some fixing for windows portability though). Make
R2FilePath::getPath return a std::string so users can allocate a std::string
on the stack and not worry about deleting the string buffer returned. Also,
use std::string in R2Fonts to avoid leaking font names. Remove R2string as
it is now replaced by std::strings.

Location:
trunk/packages/vizservers/nanovis/R2
Files:
2 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/R2/include/R2/R2FilePath.h

    r2877 r2972  
    44
    55#include <list>
    6 
    7 #include <R2/R2string.h>
     6#include <string>
    87
    98class R2FilePath
     
    1716     * @return return full path of the file, but if not found, return ""
    1817     */
    19     const char *getPath(const char *fileName);
     18    std::string getPath(const char *fileName);
    2019
    2120    /**
     
    3130
    3231private:
    33     typedef std::list<R2string> R2stringList;
    34     typedef std::list<R2string>::iterator R2stringListIter;
     32    typedef std::list<std::string> StringList;
     33    typedef std::list<std::string>::iterator StringListIter;
    3534
    3635    /// application directory
    37     static R2string _curDirectory;
     36    static std::string _curDirectory;
    3837
    3938    /// R2FilePath instance
     
    4140
    4241    /// all default file paths
    43     R2stringList _pathList;
     42    StringList _pathList;
    4443};
    4544
  • trunk/packages/vizservers/nanovis/R2/include/R2/R2Fonts.h

    r2841 r2972  
    44
    55#include <vector>
     6#include <string>
    67
    78#include <R2/R2.h>
    89#include <R2/R2Object.h>
    9 #include <R2/R2string.h>
    1010
    1111class R2Fonts : public R2Object
    1212{
    1313    struct R2FontAttributes {
    14         char *_fontName;
     14        std::string _fontName;
    1515        int _textureWidth;
    1616        int _textureHeight;
     
    2929        R2CharInfo _chars[256];
    3030    };
    31    
     31
    3232    typedef std::vector<R2FontAttributes>  R2FontVector;
    3333
  • trunk/packages/vizservers/nanovis/R2/src/Makefile.in

    r2896 r2972  
    4444                R2IndexBuffer.o \
    4545                R2Object.o \
    46                 R2VertexBuffer.o \
    47                 R2string.o
     46                R2VertexBuffer.o
    4847
    4948R2LIB           = R2.a
  • trunk/packages/vizservers/nanovis/R2/src/R2FilePath.cpp

    r2857 r2972  
    1313#include "Trace.h"
    1414
    15 R2string R2FilePath::_curDirectory;
     15std::string R2FilePath::_curDirectory;
    1616R2FilePath R2FilePath::_instance;
    1717
    18 char seps[] = ":";
     18static char seps[] = ":";
    1919
    2020R2FilePath::R2FilePath()
     
    2222    char buff[BUFSIZ+2];
    2323#ifdef _WIN32
    24     _getcwd(buff, 255);
     24    _getcwd(buff, sizeof(buff)-1);
    2525#else
    26     if (getcwd(buff, BUFSIZ) == NULL) {
     26    if (getcwd(buff, sizeof(buff)-1) == NULL) {
    2727        ERROR("can't get current working directory\n");
    2828    }
     
    3737R2FilePath::setPath(const char *filePath)
    3838{
    39     char buff[255];
     39    char buff[256];
    4040
    4141    if (filePath == NULL) {
     
    5555        if (*p == '/') {
    5656            if (*last == '/' || *last == '\\') {
    57                 _pathList.push_back(R2string(p));
     57                _pathList.push_back(std::string(p));
    5858            } else {
    59                 _pathList.push_back(R2string(p) + "/");
     59                _pathList.push_back(std::string(p) + "/");
    6060            }
    6161        } else {
    6262            if (*last == '/' || *last == '\\') {
    63                 _pathList.push_back(_curDirectory + R2string(p));
     63                _pathList.push_back(_curDirectory + std::string(p));
    6464            } else {
    65                 _pathList.push_back(_curDirectory + R2string(p) + "/");
     65                _pathList.push_back(_curDirectory + std::string(p) + "/");
    6666            }
    6767        }
     
    7676}
    7777
    78 const char *
     78std::string
    7979R2FilePath::getPath(const char* fileName)
    8080{
    81     R2string path;
     81    std::string path;
    8282
    83     R2stringListIter iter;
    84     int nameLength = strlen(fileName);
    85     for (iter = _pathList.begin(); iter != _pathList.end(); ++iter) {
    86         char *path;
     83    for (StringListIter iter = _pathList.begin();
     84         iter != _pathList.end(); ++iter) {
     85        path = *iter + std::string(fileName);
    8786
    88         path = new char[strlen((char *)(*iter)) + 1 + nameLength + 1];
    89         //sprintf(path, "%s/%s", (char *)(*iter), fileName);
    90         sprintf(path, "%s%s", (char *)(*iter), fileName);
    91         if (access(path, R_OK) == 0) {
     87        if (access(path.c_str(), R_OK) == 0) {
    9288            return path;
     89        } else {
     90            path = "";
    9391        }
    94         delete [] path;
    9592    }
    96     return NULL;
     93    return path;
    9794}
    9895
    9996void
    100 R2FilePath::setWorkingDirectory(int argc, const char** argv)
     97R2FilePath::setWorkingDirectory(int argc, const char **argv)
    10198{
    102     char buff[255];
     99    char buff[256];
    103100
    104101    strcpy(buff, argv[0]);
    105102    for (int i = strlen(buff) - 1; i >= 0; --i) {
    106103        if (buff[i] == '\\' || buff[i] == '/') {
    107             buff[i] = '/'; 
    108             buff[i + 1] = '\0'; 
     104            buff[i] = '/';
     105            buff[i + 1] = '\0';
    109106            break;
    110107        }
  • trunk/packages/vizservers/nanovis/R2/src/R2Fonts.cpp

    r2953 r2972  
    3434        unsigned int i;
    3535        for (i = 0; i < _fonts.size(); ++i) {
    36             if (strcmp(_fonts[i]._fontName, fontName) == 0) {
     36            if (strcmp(_fonts[i]._fontName.c_str(), fontName) == 0) {
    3737                _fontIndex = i;
    3838                break;
     
    142142    bool bSuccess = false;
    143143
    144     const char *path = R2FilePath::getInstance()->getPath(fontFileName);
    145     if (path == NULL) {
     144    std::string path = R2FilePath::getInstance()->getPath(fontFileName);
     145    if (path.empty()) {
    146146        return false;
    147147    }
    148     std::ifstream fsInput(path, std::ios::binary);
     148    std::ifstream fsInput(path.c_str(), std::ios::binary);
    149149    if (fsInput) {
    150         sFont._fontName = new char [strlen(fontName)+1];
    151         strcpy(sFont._fontName, fontName);
     150        sFont._fontName = fontName;
    152151
    153152        // make sure this file is the correct type by checking the header
     
    230229        fsInput.close();
    231230    }
    232     delete [] path;
    233231    return bSuccess;
    234232}
Note: See TracChangeset for help on using the changeset viewer.