Changeset 1772 for trunk


Ignore:
Timestamp:
22/11/11 16:58:21 (6 months ago)
Author:
Freddie Akeroyd
Message:

Merge in a few updates from Mantid version. Refs #303

Location:
trunk/bindings/cpp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bindings/cpp/NeXusFile.cpp

    r1771 r1772  
    165165} 
    166166 
    167 File::File(char *filename, const NXaccess access) : m_close_handle (true) { 
     167File::File(const char *filename, const NXaccess access) : m_close_handle (true) { 
    168168  this->initOpenFile(string(filename), access); 
    169169} 
     
    269269 
    270270std::string File::getPath(){ 
    271   char cPath[1024]; 
    272  
    273   memset(cPath,0,1024*sizeof(char)); 
    274   NXstatus status = NXgetpath(this->m_file_id,cPath, 1024); 
     271  char cPath[2048]; 
     272 
     273  memset(cPath,0,sizeof(cPath)); 
     274  NXstatus status = NXgetpath(this->m_file_id,cPath, sizeof(cPath)-1); 
    275275  if (status != NX_OK) { 
    276276    stringstream msg; 
     
    555555template <typename NumT> 
    556556void File::putAttr(const std::string& name, const NumT value) { 
     557  NumT data[1]; 
     558  data[0] = value; 
    557559  AttrInfo info; 
    558560  info.name = name; 
     
    920922  } 
    921923  char* value = new char[info.dims[0]+1]; // probably do not need +1, but being safe 
    922   this->getData(value); 
     924  try{ 
     925     this->getData(value); 
     926  } 
     927  catch (const Exception& e) 
     928  { 
     929    delete[] value; 
     930    throw e; 
     931  } 
    923932  res = string(value, info.dims[0]); 
    924933  delete[] value; 
     
    971980} 
    972981 
    973 void File::getEntries(std::map<std::string, std::string> & map) 
    974 { 
     982void File::getEntries(std::map<std::string, std::string> & result) 
     983{ 
     984  result.clear(); 
    975985  this->initGroupDir(); 
    976986  pair<string,string> temp; 
     
    981991    } 
    982992    else { 
    983       map.insert(temp); 
     993            result.insert(temp); 
    984994    } 
    985995  } 
  • trunk/bindings/cpp/NeXusFile.hpp

    r1742 r1772  
    181181     * \param access How to access the file. 
    182182     */ 
    183     File(char *filename, const NXaccess access = NXACC_READ); 
     183    File(const char *filename, const NXaccess access = NXACC_READ); 
    184184 
    185185    /** 
     
    687687     * but avoids the map copy of getEntries(). 
    688688     * 
    689      * \param map The map that will be filled with the entries 
    690      */ 
    691     void getEntries(std::map<std::string, std::string> & map); 
     689     * \param result The map that will be filled with the entries 
     690     */ 
     691    void getEntries(std::map<std::string, std::string> & result); 
    692692 
    693693    /** 
  • trunk/bindings/cpp/NeXusStream.hpp

    r1536 r1772  
    129129        Attr(const std::string& name, const Attr& d) { m_holder = d.m_holder->clone(); setName(name); } 
    130130        Attr(const Attr& a) : m_holder(NULL) {  m_holder = a.m_holder->clone(); } 
    131         Attr& operator=(const Attr& a) { if (this != &a) { delete m_holder; m_holder = a.m_holder->clone(); return *this; } } 
     131        Attr& operator=(const Attr& a) { if (this != &a) { delete m_holder; m_holder = a.m_holder->clone(); } return *this; } 
    132132        void setName(const std::string& name) { m_holder->setName(name); } 
    133133        virtual void readFromFile(File& nf) const { m_holder->readFromFile(nf); } 
     
    268268          } 
    269269        Data(const Data& d) : ObjectWithAttr(d), m_holder(NULL) { m_holder = d.m_holder->clone(); } 
    270         Data& operator=(const Data& d) { if (this != &d) { delete m_holder; m_holder = d.m_holder->clone(); return *this; } } 
     270        Data& operator=(const Data& d) { if (this != &d) { delete m_holder; m_holder = d.m_holder->clone(); } return *this; } 
    271271        virtual void readFromFile(File& nf) const; 
    272272        virtual void writeToFile(File& nf) const; 
Note: See TracChangeset for help on using the changeset viewer.