Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://gitlab.inria.fr/line/aide-group/macrovsa
16 May 2026, 22:45:59 UTC
  • Code
  • Branches (1)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    No releases to show
  • d85ce8c
  • /
  • src
  • /
  • RelationalMap.cpp
Raw File Download Save again
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
origin badgecontent badge
swh:1:cnt:3336d97a260db0391503c9b064de7b78330a2a23
origin badgedirectory badge
swh:1:dir:b8157120e03f8858febdc76e496e300e843c5750
origin badgerevision badge
swh:1:rev:31a87d848f8ab28a06ccf77d0b359fc966974138
origin badgesnapshot badge
swh:1:snp:ffb1e6ef77e78b82672462770a7171c80c299b3b

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
Tip revision: 31a87d848f8ab28a06ccf77d0b359fc966974138 authored by vthierry on 15 December 2025, 21:31:50 UTC
sync from makefile
Tip revision: 31a87d8
RelationalMap.cpp
#include "RelationalMap.hpp"
#include "Binding.hpp"
#include "LValue.hpp"
#include "file.hpp"
#include "regex.hpp"

namespace macrovsa {
  void RelationalMap::add(const Symbol& subject, const Symbol& predicate, const Symbol& object)
  {
    Binding binding_po(predicate, object), binding_spo(subject, binding_po);
    Bundling::add(binding_spo);
  }
  void RelationalMap::add(const RelationalMap& map)
  {
    for(auto it = map.Bundling::get().cbegin(); it != map.Bundling::get().cend(); it++) {
      const Binding& binding_spo = dynamic_cast < const Binding& > (*(it->second));
      const Binding& binding_po = dynamic_cast < const Binding& > (binding_spo.x());
      const Symbol& subject = binding_spo.y(), & predicate = binding_po.y(), & object = binding_po.x();
      add(subject, predicate, object);
    }
  }
  void RelationalMap::add(String filename)
  {
    wjson::Value triples = wjson::LValue::readTriples(aidesys::load(filename));
    for(unsigned int i = 0; i < triples.length(); i++) {
      add(triples.at(i).at(0).asString(), triples.at(i).at(1).asString(), triples.at(i).at(2).asString());
    }
  }
  std::string RelationalMap::asString() const
  {
    std::string result = wjson::quote(getName()) + ": {\n";
    for(auto it = Bundling::get().cbegin(); it != Bundling::get().cend(); it++) {
      const Binding& binding_spo = dynamic_cast < const Binding& > (*(it->second));
      const Binding& binding_po = dynamic_cast < const Binding& > (binding_spo.x());
      const Symbol& subject = binding_spo.y(), & predicate = binding_po.y(), & object = binding_po.x();
      result += "  [ " + subject.asString() + predicate.asString() + " " + object.asString() + " ]\n";
    }
    return result + "}" + asStringTail() + "\n";
  }
  std::string RelationalMap::asString(const Symbol& subject, const Symbol& predicate, const Symbol& object)
  {
    Binding binding_po(predicate, object), binding_spo(subject, binding_po);
    return "[ " + subject.asString() + " " + predicate.asString() + " " + object.asString() + " ]" + binding_spo.asStringTail();
  }
  void RelationalMap::save(String filename) const
  {
    class TripleWriter {
      std::string filename;
      std::string prefixes = (std::string)
                             "\n@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ." +
                             "\n@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .";
      std::string triples;
      String quoteTurtleSymbol(const Symbol& symbol)
      {
        static std::string string;
        string = symbol.asString();
        if(aidesys::regexMatch(string, "^[a-z]*:.*")) {
          String prefix = aidesys::regexReplace(string, "^([^:]*):.*", "$1");
          if(prefixes.find("\n@prefix " + prefix + ":") == std::string::npos) {
            prefixes += "\n@prefix " + prefix + ": <file://" + filename + "#" + prefix + "> .";
          }
        } else {
          string = "\"" + aidesys::regexReplace(string, "\"", "\"\"\"") + "\"";
        }
        return string;
      }
public:
      void save(String filename, const RelationalMap& map)
      {
        this->filename = filename;
        for(auto it = map.Bundling::get().cbegin(); it != map.Bundling::get().cend(); it++) {
          const Binding& binding_spo = dynamic_cast < const Binding& > (*(it->second));
          const Binding& binding_po = dynamic_cast < const Binding& > (binding_spo.x());
          const Symbol& subject = binding_spo.y(), & predicate = binding_po.y(), & object = binding_po.x();
          triples += quoteTurtleSymbol(subject) + " " + quoteTurtleSymbol(predicate) + " " + quoteTurtleSymbol(object) + " .\n";
        }
        aidesys::save(filename, "@base <file://" + filename + "#> ." + prefixes + "\n" + triples);
      }
    }
    tripleWriter;
    tripleWriter.save(filename, *this);
  }
}

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API