示例#1
0
bool DataList::Remove(PNode node)
{
    if (!node.Ok())
        return false;
    if (nodes.erase(BA::to_lower_copy(node->Name())) <= 0)
        return false;

    node->parent = NULL;
    node->ListRemove();
    return true;
}
示例#2
0
bool DataList::Rename(const std::string& old_name, const std::string& new_name)
{
    // check that new name is not used up.
    if (nodes.find(BA::to_lower_copy(new_name)) != nodes.end())
        return false;
    nodes_iterator i = nodes.find(BA::to_lower_copy(old_name));
    if (i == nodes.end())
        return false;
    PNode node = i->second;

    ASSERT_LOGIC(node.Ok(), "Internal TDF tree consistency (1)");
    ASSERT_LOGIC(node->Name().Lower() == old_name.Lower(), "Internal TDF tree consistency (2)");

    node->name = BA::to_lower_copy(new_name);
    nodes.erase(i);
    bool inserted = nodes.insert(std::pair<std::string, PNode>(BA::to_lower_copy(node->name), node)).second;
    ASSERT_LOGIC(inserted, "DataList::Rename failed");
    return inserted;
}
示例#3
0
void DataList::InsertRenameAt(PNode node, PNode where)
{   // rename if such entry already exists. str contains new name.
    if (!node.Ok())
        return;
    if (!where->list_prev)
        return;

    if (!InsertAt(node, where)) {
        for (int n = 0; n < 10000; ++n) {
            std::ostringstream os;
            os << node->Name() << rename_prefix << n;
            node->name = os.str();
            if (InsertAt(node, where)) {
                return;
            }
        }
        LslError("insertRename: iterated over 10 000 names, way too many");
    }
}
示例#4
0
void DataList::InsertRename(PNode node)
{   /// rename if such entry already exists. str contains new name.
    if (!node.Ok())
        return;

    if (!Insert(node)) {
        std::string original_name = node->Name();
        for (int n = 0; n < 10000; ++n) {
            //std::string tmp=str+std::string(rename_prefix);
            std::ostringstream os;
            os << original_name << rename_prefix << n;
            node->name = os.str();
            if (Insert(node)) {
                return;
            }
        }
        LslError("insertRename: iterated over 10 000 names, way too many");
    }
}