# IRI

IRIs, including ones that are set with FuncIRI syntax, are passed to the user code the same way as other strings in SVG++.

The only setting in IRI Policy configures whether to distinguish local references to document fragment (IRIs prefixed with “#”) from non-local IRI references. If `policy::iri::distinguish_local` used (as by default), then local reference to document fragment is passed as pair of parameters: {`tag::iri_fragment()`, <fragment string>}. If `policy::iri::raw` is set, then any IRI is passed as single string.

Named class template parameter for IRI Policy is `iri_policy`.

Example of using default IRI Policy (`src/samples/sample_iri.cpp`):

    #include <svgpp/svgpp.hpp>

    using namespace svgpp;

    struct Context
    {
      template<class String>
      void set(tag::attribute::xlink::href, String const & iri)
      {
        std::cout << "IRI: " << std::string(boost::begin(iri), boost::end(iri)) << "\n";
      }

      template<class String>
      void set(tag::attribute::xlink::href, tag::iri_fragment, String const & iri)
      {
        std::cout << "Fragment: " << std::string(boost::begin(iri), boost::end(iri)) << "\n";
      }
    };

    int main()
    {
      Context context;
      value_parser<tag::type::iri>::parse(tag::attribute::xlink::href(), context,
        std::string("http://foo.com/bar#123"), tag::source::attribute());
      value_parser<tag::type::iri>::parse(tag::attribute::xlink::href(), context,
        std::string("#rect1"), tag::source::attribute());
      // Output:
      //  "IRI: http://foo.com/bar#123"
      //  "Fragment: rect1"
      return 0;
    }