CubitString CubitCoordinateSystem::entity_name() const { CubitString name = class_name(); name += " "; name += CubitString( this->id() ); return name; }
CubitString CubitSimpleAttrib::character_type() const //- returns the type of attribute { if(stringDataList.size() >= 1 ) { return stringDataList[0]; } return CubitString(); }
// read from file starting at current file offset FacetAttrib* FacetAttrib::restore(FILE *restore_file, unsigned int endian) { if( restore_file == NULL ) return NULL; NCubitFile::CIOWrapper wrapper(endian, restore_file ); // write a version number for the attribute data unsigned int version; wrapper.Read(&version, 1); // haven't handled any version changes yet if( version != 1 ) { PRINT_ERROR("Wrong FacetAttrib version : %u\n", version ); return NULL; } // read the number of strings, number of doubles, and number of integers int counts[3]; wrapper.Read(reinterpret_cast<unsigned int*>(counts), 3); int n_strings = counts[0]; int n_doubles = counts[1]; int n_ints = counts[2]; // allocate arrays, but don't try to allocate zero-length array CubitString* strings = n_strings ? new CubitString[n_strings] : NULL; double *doubles = n_doubles ? new double[n_doubles] : NULL; int *ints = n_ints ? new int[n_ints] : NULL; // read the string data int i; for( i = 0; i < n_strings; i++ ) strings[i] = CubitString(wrapper.Read()); // write the doubles wrapper.Read(doubles, n_doubles); // write the integers wrapper.Read(reinterpret_cast<unsigned int*>(ints), n_ints); return new FacetAttrib(n_strings, strings, n_doubles, doubles, n_ints, ints); }
CubitString CubitString::substr(size_t first, size_t count) const { size_t len = length(); if (first >= len) return CubitString(); if (first == 0 && count >= len) return *this; if (count > len - first) count = len - first; CubitString rv; if (count > 0) { char *substring = new char[count+1]; strncpy(substring, rep->chars+first, count); substring[count] = '\0'; rv = substring; delete [] substring; } return rv; }
CubitString CubitString::segmentstr(size_t first, size_t first_not) const { if (first_not <= first) return CubitString(); return substr(first, first_not - first); }
CubitString operator+(const char *c1, const CubitString& s2) { return CubitString(c1) += s2; }
CubitString operator+(const CubitString& s1, const char *c2) { return CubitString(s1) += c2; }
CubitString operator+(const CubitString& s1, const CubitString& s2) { return CubitString(s1) += s2; }
CubitString CubitUtil::getenv(const CubitString& var) { return CubitString(::getenv(var.c_str())); }
CubitString RefEntityName::get_replacement_setting() { char tmp[] = {replacementCharacter, '\0'}; return CubitString(tmp); }
CubitString RefEntityName::get_suffix_setting() { char tmp[] = {suffixCharacter, '\0'}; return CubitString(tmp); }