// // Non-class/non-friend helper functions // std::string getDisplayableTitleFromUuid(std::string uuid) { if(uuid.empty()) return std::string(); // need to find the item with the associated UUID boost::shared_ptr<Student> student; if(PDM().getItemByUuid(uuid, student)) { return student->getDisplayName(); } boost::shared_ptr<Course> course; if(PDM().getItemByUuid(uuid, course)) { return course->getCourseName(); } boost::shared_ptr<EvalSet> evalSet; if(PDM().getItemByUuid(uuid, evalSet)) { return evalSet->getEvalSetName(); } // nothing found, return a string indicating an error assert(false); throw ItemNotFoundException("Item not found with UUID: " + uuid); }
std::string getDeviceByUuid(std::string const& uuid) const { for (std::map<std::string, std::map<std::string, std::string> >::const_iterator iter = this->begin(); iter != this->end(); iter++) { if (iter->second.find("UUID") != iter->second.end() && iter->second.at("UUID") == uuid) { return iter->first; } } throw ItemNotFoundException("no device found by uuid " + uuid, __FILE__, __LINE__); }
void HashTable<Object>::remove( const Object & x ) { int currentPos = findPos( x ); if( isActive( currentPos ) ) array[ currentPos ].info = DELETED; else throw ItemNotFoundException( ); }
bool XmlUtil::get_bool_property(const xmlNodePtr node, const String &property) { const xmlAttr *attr; if (node == 0) { EL_THROW_EXCEPTION(InvalidParameterException() << errinfo_message(UTF8("parameter is zero")) << errinfo_parameter_name(UTF8("node"))); } for (attr = node->properties; attr; attr = attr->next) { if ((attr->type == XML_ATTRIBUTE_NODE) && (xmlStrcasecmp(attr->name, BAD_CAST property.get().c_str()) == 0)) { if (attr->children == 0) { return false; } if (xmlStrcmp(attr->children->content, BAD_CAST UTF8("true")) == 0) { return true; } if (xmlStrcmp(attr->children->content, BAD_CAST UTF8("yes")) == 0) { return true; } if (xmlStrcmp(attr->children->content, BAD_CAST UTF8("false")) == 0) { return false; } if (xmlStrcmp(attr->children->content, BAD_CAST UTF8("no")) == 0) { return false; } return boost::lexical_cast<bool>( attr->children->content); } } EL_THROW_EXCEPTION(ItemNotFoundException() << errinfo_message(UTF8("Property not found")) << errinfo_item_name(property) << errinfo_parameter_name((char*)node->name)); }
UserData* UserController :: checkIn(std::string ID, std::string passwd) { Logging log("UserController :: checkIn",true); UserData* toReturn = findUser(ID); if(toReturn) { if(toReturn->Password() == passwd) return toReturn; else throw PasswordNotCorrectException((std::string)"password wrong!"); } else throw ItemNotFoundException((std::string)"user not exist!"); }
void SplayTree<Comparable>::remove( const Comparable & x ) { BinaryNode<Comparable> *newTree; // If x is found, it will be at the root splay( x, root ); if( root->element != x ) throw ItemNotFoundException( ); if( root->left == nullNode ) newTree = root->right; else { // Find the maximum in the left subtree // Splay it to the root; and then attach right child newTree = root->left; splay( x, newTree ); newTree->right = root->right; } delete root; root = newTree; }