Ejemplo n.º 1
0
    id_placeholder* id_state::add_id_to_section(
            std::string const& id,
            id_category category,
            boost::intrusive_ptr<section_info> const& section)
    {
        std::string id_part = id;

        // Note: Normalizing id according to file compatibility version, but
        // adding to section according to section compatibility version.

        if (current_file->compatibility_version >= 106u &&
                category.c < id_category::explicit_id) {
            id_part = normalize_id(id);
        }

        if(!section || section->compatibility_version >= 106u) {
            return add_placeholder(id_part, category,
                section ? section->placeholder_1_6 : 0);
        }
        else {
            std::string const& qualified_id = section->id_1_1;

            std::string new_id;
            if (!section->placeholder_1_6)
                new_id = current_file->doc_id_1_1;
            if (!new_id.empty() && !qualified_id.empty()) new_id += '.';
            new_id += qualified_id;
            if (!new_id.empty() && !id_part.empty()) new_id += '.';
            new_id += id_part;

            return add_placeholder(new_id, category,
                section->placeholder_1_6);
        }
    }
Ejemplo n.º 2
0
    id_placeholder const* document_state_impl::add_id_to_section(
            boost::string_ref id,
            id_category category,
            boost::shared_ptr<section_info> const& section)
    {
        std::string id_part(id.begin(), id.end());

        // Note: Normalizing id according to file compatibility version, but
        // adding to section according to section compatibility version.

        if (current_file->compatibility_version >= 106u &&
                category.c < id_category::explicit_id) {
            id_part = normalize_id(id);
        }

        id_placeholder const* placeholder_1_6 = get_id_placeholder(section);

        if(!section || section->compatibility_version >= 106u) {
            return add_placeholder(id_part, category, placeholder_1_6);
        }
        else {
            std::string const& qualified_id = section->id_1_1;

            std::string new_id;
            if (!placeholder_1_6)
                new_id = current_file->doc_id_1_1;
            if (!new_id.empty() && !qualified_id.empty()) new_id += '.';
            new_id += qualified_id;
            if (!new_id.empty() && !id_part.empty()) new_id += '.';
            new_id += id_part;

            return add_placeholder(new_id, category, placeholder_1_6);
        }
    }
Ejemplo n.º 3
0
    id_placeholder const* document_state_impl::create_new_section(
            boost::string_ref id,
            id_category category,
            source_mode_info const& source_mode)
    {
        boost::shared_ptr<section_info> parent =
            current_file->document->current_section;

        id_placeholder const* p = 0;
        id_placeholder const* placeholder_1_6 = 0;

        std::string id_1_1;

        if (parent && current_file->compatibility_version < 106u) {
            id_1_1 = parent->id_1_1;
            if (!id_1_1.empty() && !id.empty())
                id_1_1 += ".";
            id_1_1.append(id.begin(), id.end());
        }

        if (current_file->compatibility_version >= 106u) {
            p = placeholder_1_6 = add_id_to_section(id, category, parent);
        }
        else if (current_file->compatibility_version >= 103u) {
            placeholder_1_6 = get_id_placeholder(parent);

            std::string new_id;
            if (!placeholder_1_6) {
                new_id = current_file->doc_id_1_1;
                if (!id_1_1.empty()) new_id += '.';
            }
            new_id += id_1_1;

            p = add_placeholder(new_id, category, placeholder_1_6);
        }
        else {
            placeholder_1_6 = get_id_placeholder(parent);

            std::string new_id;
            if (parent && !placeholder_1_6)
                new_id = current_file->doc_id_1_1 + '.';

            new_id += detail::to_s(id);

            p = add_placeholder(new_id, category, placeholder_1_6);
        }

        current_file->document->current_section =
            boost::make_shared<section_info>(parent,
                current_file.get(), id, id_1_1, placeholder_1_6,
                source_mode);

        return p;
    }
Ejemplo n.º 4
0
    id_placeholder* id_state::create_new_section(
            std::string const& id,
            id_category category)
    {
        boost::intrusive_ptr<section_info> parent =
            current_file->document->current_section;

        boost::intrusive_ptr<section_info> new_section =
            new section_info(parent, current_file->compatibility_version, id);

        id_placeholder* p;

        if (new_section->compatibility_version >= 106u) {
            p = add_id_to_section(id, category, parent);
            new_section->placeholder_1_6 = p;
        }
        else if (new_section->compatibility_version >= 103u) {
            if (parent)
                new_section->placeholder_1_6 = parent->placeholder_1_6;

            std::string new_id;
            if (!new_section->placeholder_1_6) {
                new_id = current_file->doc_id_1_1;
                if (!new_section->id_1_1.empty()) new_id += '.';
            }
            new_id += new_section->id_1_1;

            p = add_placeholder(new_id, category,
                new_section->placeholder_1_6);
        }
        else {
            if (parent)
                new_section->placeholder_1_6 = parent->placeholder_1_6;

            std::string new_id;
            if (parent && !new_section->placeholder_1_6)
                new_id = current_file->doc_id_1_1 + '.';

            new_id += id;

            p = add_placeholder(new_id, category,
                new_section->placeholder_1_6);
        }

        current_file->document->current_section = new_section;
        
        return p;
    }
Ejemplo n.º 5
0
 id_placeholder* id_state::old_style_id(
     std::string const& id,
     id_category category)
 {
     return current_file->compatibility_version < 103u ?
         add_placeholder(
             current_file->document->section_id_1_1 + "." + id, category) :
             add_id(id, category);
 }
Ejemplo n.º 6
0
 id_placeholder const* document_state_impl::old_style_id(
     boost::string_ref id,
     id_category category)
 {
     return current_file->compatibility_version < 103u ?
         add_placeholder(
             current_file->document->section_id_1_1 + "." + detail::to_s(id), category) :
             add_id(id, category);
 }