Changeset 1719


Ignore:
Timestamp:
27/10/11 23:04:16 (7 months ago)
Author:
Janik Zikovsky
Message:

Refs #294 : Merging more changes from Mantid NexusCPP. Changed the behavior of putAttr() to NOT throw if given an empty string.

Location:
trunk/bindings/cpp
Files:
2 edited

Legend:

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

    r1711 r1719  
    570570 
    571571void File::putAttr(const std::string& name, const std::string value) { 
    572   if (value.empty()) { 
    573     throw Exception("Supplied empty value to putAttr"); 
    574   } 
    575572  string my_value(value); 
     573  if (my_value.empty()) 
     574    my_value = " "; // Make a default "space" to avoid errors. 
    576575  AttrInfo info; 
    577576  info.name = name; 
    578   info.length = my_value.size(); 
     577  info.length = static_cast<int>(my_value.size()); 
    579578  info.type = CHAR; 
    580579  this->putAttr(info, &(my_value[0])); 
     
    960959} 
    961960 
    962 map<string, string> File::getEntries() { 
     961map<string, string> File::getEntries() 
     962{ 
     963  map<string, string> result; 
     964  this->getEntries(result); 
     965  return result; 
     966} 
     967 
     968void File::getEntries(std::map<std::string, std::string> & map) 
     969{ 
    963970  this->initGroupDir(); 
    964  
    965   map<string, string> result; 
    966  
    967971  pair<string,string> temp; 
    968972  while (true) { 
     
    972976    } 
    973977    else { 
    974       result.insert(temp); 
     978      map.insert(temp); 
    975979    } 
    976980  } 
    977  
    978   return result; 
    979 } 
     981} 
     982 
    980983 
    981984void File::getSlab(void* data, const vector<int>& start, 
     
    11271130  return infos; 
    11281131} 
     1132 
     1133bool File::hasAttr(const std::string & name) 
     1134{ 
     1135  this->initAttrDir(); 
     1136  AttrInfo temp; 
     1137  while(true) { 
     1138    temp = this->getNextAttr(); 
     1139    if (temp.name == NULL_STR) { 
     1140      break; 
     1141    } 
     1142    if (temp.name == name) 
     1143      return true; 
     1144  } 
     1145  return false; 
     1146} 
     1147 
    11291148 
    11301149NXlink File::getGroupID() { 
     
    17201739NXDLL_EXPORT void File::putSlab(std::vector<uint64_t>& data, int start, int size); 
    17211740 
     1741template 
     1742NXDLL_EXPORT void File::putSlab(std::vector<float>& data, std::vector<int64_t> & start, std::vector<int64_t> & size); 
     1743template 
     1744NXDLL_EXPORT void File::putSlab(std::vector<double>& data, std::vector<int64_t> & start, std::vector<int64_t> & size); 
     1745template 
     1746NXDLL_EXPORT void File::putSlab(std::vector<int8_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size); 
     1747template 
     1748NXDLL_EXPORT void File::putSlab(std::vector<uint8_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size); 
     1749template 
     1750NXDLL_EXPORT void File::putSlab(std::vector<int16_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size); 
     1751template 
     1752NXDLL_EXPORT void File::putSlab(std::vector<uint16_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size); 
     1753template 
     1754NXDLL_EXPORT void File::putSlab(std::vector<int32_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size); 
     1755template 
     1756NXDLL_EXPORT void File::putSlab(std::vector<uint32_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size); 
     1757template 
     1758NXDLL_EXPORT void File::putSlab(std::vector<int64_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size); 
     1759template 
     1760NXDLL_EXPORT void File::putSlab(std::vector<uint64_t>& data, std::vector<int64_t> & start, std::vector<int64_t> & size); 
     1761 
    17221762template  
    17231763NXDLL_EXPORT void File::getAttr(const std::string& name, double& value); 
  • trunk/bindings/cpp/NeXusFile.hpp

    r1711 r1719  
    673673    std::map<std::string, std::string> getEntries(); 
    674674 
     675    /** Return the entries available in the current place in the file, 
     676     * but avoids the map copy of getEntries(). 
     677     * 
     678     * \param map The map that will be filled with the entries 
     679     */ 
     680    void getEntries(std::map<std::string, std::string> & map); 
     681 
    675682    /** 
    676683     * \copydoc NeXus::File::getSlab(void*, const std::vector<int64_t>&, 
     
    696703     */ 
    697704    std::vector<AttrInfo> getAttrInfos(); 
     705 
     706    /** 
     707     *  \return true if the current point in the file has the named attribute 
     708     *  \param name the name of the attribute to look for. 
     709     */ 
     710    bool hasAttr(const std::string & name); 
    698711 
    699712    /** 
Note: See TracChangeset for help on using the changeset viewer.