Changeset 1237

Show
Ignore:
Timestamp:
06/08/08 19:32:50 (3 months ago)
Author:
drobilla
Message:

Use less ugly blank node IDs.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • redlandmm/redlandmm/World.hpp

    r937 r1237  
    2121#include <stdexcept> 
    2222#include <string> 
     23#include <set> 
    2324#include <librdf.h> 
    2425#include <boost/utility.hpp> 
     
    5657        Namespaces    _prefixes; 
    5758 
    58         size_t _next_blank_id
     59        std::set<std::string> _blank_ids
    5960}; 
    6061 
  • redlandmm/src/World.cpp

    r937 r1237  
    3535 */ 
    3636World::World() 
    37         : _next_blank_id(1) 
    3837{ 
    3938        _c_obj = librdf_new_world(); 
     
    8786World::blank_id(const string base_name) 
    8887{ 
     88        /* 
    8989        std::ostringstream ss; 
    9090        ss << "b" << _next_blank_id++; 
     
    9696        assert(result.to_string() == ss.str()); 
    9797        return result; 
     98        */ 
     99 
     100        string name = base_name; 
     101        for (unsigned i = 2; _blank_ids.find(name) != _blank_ids.end(); ++i) { 
     102                std::ostringstream ss; 
     103                ss << "_" << i; 
     104                name = ss.str(); 
     105        } 
     106         
     107        Node result = Node(*this, Node::BLANK, name); 
     108        assert(result.to_string() == name); 
     109        return result; 
    98110} 
    99111