class Paludis::MetadataSectionKey

A MetadataSectionKey is a MetadataKey that holds a number of other MetadataKey instances.

Public Instance Methods

[String] → MetadataKey or Nil click to toggle source

The named metadata key

VALUE
    metadata_section_key_subscript(VALUE self, VALUE raw_name)
    {
        std::shared_ptr<const MetadataKey> * self_ptr;
        Data_Get_Struct(self, std::shared_ptr<const MetadataKey>, self_ptr);
        std::shared_ptr<const MetadataSectionKey> c = std::static_pointer_cast<const MetadataSectionKey>(*self_ptr);
        MetadataSectionKey::MetadataConstIterator it((c)->find_metadata(StringValuePtr(raw_name)));
        if (c->end_metadata() == it)
            return Qnil;
        return metadata_key_to_value(*it);
    }

    void do_register_metadata_key()
    {
        /*
         * Document-class: Paludis::MetadataKey
         *
         * Base metadata class, subclasses contain a "parse_value" to return the contents of the key.
         */
        c_metadata_key = rb_define_class_under(c_paludis_module, "MetadataKey", rb_cObject);
        rb_funcall(c_metadata_key, rb_intern("private_class_method"), 1, rb_str_new2("new"));
        rb_define_method(c_metadata_key, "raw_name", template_methods, 0);
        rb_define_method(c_metadata_key, "human_name", template_methods, 0);
        rb_define_method(c_metadata_key, "type", metadata_key_type, 0);

        /*
         * Document-class: Paludis::MetadataPackageIDKey
         *
         * Metadata class for a PackageId.
         */
        c_metadata_package_id_key = rb_define_class_under(c_paludis_module, "MetadataPackageIDKey", c_metadata_key);
        rb_define_method(c_metadata_package_id_key, "parse_value", metadata_package_id_key_value, 0);

        /*
         * Document-class: Paludis::MetadataStringKey
         *
         * Metadata class for Strings.
         */
        c_metadata_string_key = rb_define_class_under(c_paludis_module, "MetadataStringKey", c_metadata_key);
        rb_define_method(c_metadata_string_key, "parse_value", metadata_string_key_value, 0);

        /*
         * Document-class: Paludis::MetadataSlotNameKey
         *
         * Metadata class for SlotNames.
         */
        c_metadata_slot_key = rb_define_class_under(c_paludis_module, "MetadataSlotNameKey", c_metadata_key);
        rb_define_method(c_metadata_slot_key, "parse_value", metadata_slot_key_value, 0);

        /*
         * Document-class: Paludis::MetadataSizeKey
         *
         * Metadata class for file sizes.
         */
        c_metadata_size_key = rb_define_class_under(c_paludis_module, "MetadataSizeKey", c_metadata_key);
        rb_define_method(c_metadata_size_key, "parse_value", metadata_size_key_value, 0);

        /*
         * Document-class: Paludis::MetadataFSPathKey
         *
         * Metadata class for FSPath.
         */
        c_metadata_fsentry_key = rb_define_class_under(c_paludis_module, "MetadataFSPathKey", c_metadata_key);
        rb_define_method(c_metadata_fsentry_key, "parse_value", metadata_fsentry_key_value, 0);

        /*
         * Document-class: Paludis::MetadataTimeKey
         *
         * Metadata class for Time.
         */
        c_metadata_time_key = rb_define_class_under(c_paludis_module, "MetadataTimeKey", c_metadata_key);
        rb_define_method(c_metadata_time_key, "parse_value", metadata_time_key_value, 0);

        /*
         * Document-class: Paludis::MetadataChoicesKey
         *
         * Metadata class for Choices.
         */
        c_metadata_choices_key = rb_define_class_under(c_paludis_module, "MetadataChoicesKey", c_metadata_key);
        rb_define_method(c_metadata_choices_key, "parse_value", metadata_choices_key_value, 0);

        /*
         * Document-class: Paludis::MetadataKeywordNameSetKey
         *
         * Metadata class for keywords.
         */
        c_metadata_keyword_name_set_key = rb_define_class_under(c_paludis_module, "MetadataKeywordNameSetKey", c_metadata_key);
        rb_define_method(c_metadata_keyword_name_set_key, "parse_value", template_methods, 0);

        /*
         * Document-class: Paludis::MetadataPackageIDSequenceKey
         *
         * Metadata class for package IDs.
         */
        c_metadata_package_id_sequence_key = rb_define_class_under(c_paludis_module, "MetadataPackageIDSequenceKey", c_metadata_key);
        rb_define_method(c_metadata_package_id_sequence_key, "parse_value", template_methods, 0);

        /*
         * Document-class: Paludis::MetadataFSPathSequenceKey
         *
         * Metadata class for filesystem sequences.
         */
        c_metadata_fsentry_sequence_key = rb_define_class_under(c_paludis_module, "MetadataFSPathSequenceKey", c_metadata_key);
        rb_define_method(c_metadata_fsentry_sequence_key, "parse_value", template_methods, 0);

        /*
         * Document-class: Paludis::MetadataMaintainersKey
         *
         * Metadata class for maintainers.
         */
        c_metadata_maintainers_key = rb_define_class_under(c_paludis_module, "MetadataMaintainersKey", c_metadata_key);
        rb_define_method(c_metadata_maintainers_key, "parse_value", template_methods, 0);

        /*
         * Document-class: Paludis::MetadataStringSetKey
         *
         * Metadata class for String sets.
         */
        c_metadata_string_set_key = rb_define_class_under(c_paludis_module, "MetadataStringSetKey", c_metadata_key);
        rb_define_method(c_metadata_string_set_key, "parse_value", SetValue<Set<std::string> >::fetch, 0);

        /*
         * Document-class: Paludis::MetadataStringStringMapKey
         *
         * Metadata class for String to String maps.
         */
        c_metadata_string_string_map_key = rb_define_class_under(c_paludis_module, "MetadataStringStringMapKey", c_metadata_key);
        rb_define_method(c_metadata_string_string_map_key, "parse_value", MapValue<Map<std::string, std::string> >::fetch, 0);

        /*
         * Document-class: Paludis::MetadataStringSequenceKey
         *
         * Metadata class for String sequences.
         */
        c_metadata_string_sequence_key = rb_define_class_under(c_paludis_module, "MetadataStringSequenceKey", c_metadata_key);
        rb_define_method(c_metadata_string_sequence_key, "parse_value", SetValue<Sequence<std::string> >::fetch, 0);

        /*
         * Document-class: Paludis::MetadataLicenseSpecTreeKey
         *
         * Metadata class for license specs.
         */
        c_metadata_license_spec_tree_key = rb_define_class_under(c_paludis_module, "MetadataLicenseSpecTreeKey", c_metadata_key);
        rb_define_method(c_metadata_license_spec_tree_key, "parse_value", template_methods, 0);

        /*
         * Document-class: Paludis::MetadataPlainTextSpecTreeKey
         *
         * Metadata class for restrict specs.
         */
        c_metadata_plain_text_spec_tree_key = rb_define_class_under(c_paludis_module, "MetadataPlainTextSpecTreeKey", c_metadata_key);
        rb_define_method(c_metadata_plain_text_spec_tree_key, "parse_value", template_methods, 0);

        /*
         * Document-class: Paludis::MetadataRequiredUseSpecTreeKey
         *
         * Metadata class for restrict specs.
         */
        c_metadata_required_use_spec_tree_key = rb_define_class_under(c_paludis_module, "MetadataRequiredUseSpecTreeKey", c_metadata_key);
        rb_define_method(c_metadata_required_use_spec_tree_key, "parse_value", template_methods, 0);

        /*
         * Document-class: Paludis::MetadataDependencySpecTreeKey
         *
         * Metadata class for dependency specs.
         */
        c_metadata_dependency_spec_tree_key = rb_define_class_under(c_paludis_module, "MetadataDependencySpecTreeKey", c_metadata_key);
        rb_define_method(c_metadata_dependency_spec_tree_key, "parse_value", template_methods, 0);
        rb_define_method(c_metadata_dependency_spec_tree_key, "initial_labels", metadata_dependency_spec_tree_key_initial_labels, 0);

        /*
         * Document-class: Paludis::MetadataFetchableURISpecTreeKey
         *
         * Metadata class for fetchable uri specs.
         */
        c_metadata_fetchable_uri_spec_tree_key = rb_define_class_under(c_paludis_module, "MetadataFetchableURISpecTreeKey", c_metadata_key);
        rb_define_method(c_metadata_fetchable_uri_spec_tree_key, "parse_value", template_methods, 0);
        rb_define_method(c_metadata_fetchable_uri_spec_tree_key, "initial_label", metadata_fetchable_uri_spec_tree_key_initial_label, 0);

        /*
         * Document-class: Paludis::MetadataSimpleURISpecTreeKey
         *
         * Metadata class for simple uri specs.
         */
        c_metadata_simple_uri_spec_tree_key = rb_define_class_under(c_paludis_module, "MetadataSimpleURISpecTreeKey", c_metadata_key);
        rb_define_method(c_metadata_simple_uri_spec_tree_key, "parse_value", template_methods, 0);

        /*
         * Document-class: Paludis::MetadataSectionKey
         *
         * A MetadataSectionKey is a MetadataKey that holds a number of other
         * MetadataKey instances.
         */
        c_metadata_section_key = rb_define_class_under(c_paludis_module, "MetadataSectionKey", c_metadata_key);
        rb_define_method(c_metadata_section_key, "each_metadata", metadata_section_key_each_metadata, 0);
        rb_define_method(c_metadata_section_key, "[]", metadata_section_key_subscript, 1);

        /*
         * Document-module: Paludis::MetadataKeyType
         *
         * The significance of a MetadataKey to a user.
         */
        c_metadata_key_type = rb_define_module_under(c_paludis_module, "MetadataKeyType");
        for (MetadataKeyType l(static_cast<MetadataKeyType>(0)), l_end(last_mkt) ; l != l_end ;
                l = static_cast<MetadataKeyType>(static_cast<int>(l) + 1))
            rb_define_const(c_metadata_key_type, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));

/*
*A key of significant interest, to be shown early on
*/
rb_define_const(c_metadata_key_type, "Significant", 0);
/*
*A normal key, to be shown underneath mkt_significant keys
*/
rb_define_const(c_metadata_key_type, "Normal", 1);
/*
*Should only be shown if the user asks for author information
*/
rb_define_const(c_metadata_key_type, "Author", 2);
/*
*Should only be shown if the user asks for dependencies
*/
rb_define_const(c_metadata_key_type, "Dependencies", 3);
/*
*Should not usually be displayed to the user
*/
rb_define_const(c_metadata_key_type, "Internal", 4);    }
}
each_metadata {|key| block } → Nil click to toggle source

Our metadata.

VALUE
    metadata_section_key_each_metadata(VALUE self)
    {
        std::shared_ptr<const MetadataKey> * self_ptr;
        Data_Get_Struct(self, std::shared_ptr<const MetadataKey>, self_ptr);
        std::shared_ptr<const MetadataSectionKey> c = std::static_pointer_cast<const MetadataSectionKey>(*self_ptr);
        for (MetadataSectionKey::MetadataConstIterator it((c)->begin_metadata()),
                it_end((c)->end_metadata()); it_end != it; ++it)
        {
            VALUE val(metadata_key_to_value(*it));
            if (Qnil != val)
                rb_yield(val);
        }
        return Qnil;
    }

    /*
     * call-seq:
     *     [String] -> MetadataKey or Nil
     *
     * The named metadata key
     */
    VALUE
    metadata_section_key_subscript(VALUE self, VALUE raw_name)
    {
        std::shared_ptr<const MetadataKey> * self_ptr;
        Data_Get_Struct(self, std::shared_ptr<const MetadataKey>, self_ptr);
        std::shared_ptr<const MetadataSectionKey> c = std::static_pointer_cast<const MetadataSectionKey>(*self_ptr);
        MetadataSectionKey::MetadataConstIterator it((c)->find_metadata(StringValuePtr(raw_name)));
        if (c->end_metadata() == it)
            return Qnil;
        return metadata_key_to_value(*it);
    }

    void do_register_metadata_key()
    {
        /*
         * Document-class: Paludis::MetadataKey
         *
         * Base metadata class, subclasses contain a "parse_value" to return the contents of the key.
         */
        c_metadata_key = rb_define_class_under(c_paludis_module, "MetadataKey", rb_cObject);
        rb_funcall(c_metadata_key, rb_intern("private_class_method"), 1, rb_str_new2("new"));
        rb_define_method(c_metadata_key, "raw_name", template_methods, 0);
        rb_define_method(c_metadata_key, "human_name", template_methods, 0);
        rb_define_method(c_metadata_key, "type", metadata_key_type, 0);

        /*
         * Document-class: Paludis::MetadataPackageIDKey
         *
         * Metadata class for a PackageId.
         */
        c_metadata_package_id_key = rb_define_class_under(c_paludis_module, "MetadataPackageIDKey", c_metadata_key);
        rb_define_method(c_metadata_package_id_key, "parse_value", metadata_package_id_key_value, 0);

        /*
         * Document-class: Paludis::MetadataStringKey
         *
         * Metadata class for Strings.
         */
        c_metadata_string_key = rb_define_class_under(c_paludis_module, "MetadataStringKey", c_metadata_key);
        rb_define_method(c_metadata_string_key, "parse_value", metadata_string_key_value, 0);

        /*
         * Document-class: Paludis::MetadataSlotNameKey
         *
         * Metadata class for SlotNames.
         */
        c_metadata_slot_key = rb_define_class_under(c_paludis_module, "MetadataSlotNameKey", c_metadata_key);
        rb_define_method(c_metadata_slot_key, "parse_value", metadata_slot_key_value, 0);

        /*
         * Document-class: Paludis::MetadataSizeKey
         *
         * Metadata class for file sizes.
         */
        c_metadata_size_key = rb_define_class_under(c_paludis_module, "MetadataSizeKey", c_metadata_key);
        rb_define_method(c_metadata_size_key, "parse_value", metadata_size_key_value, 0);

        /*
         * Document-class: Paludis::MetadataFSPathKey
         *
         * Metadata class for FSPath.
         */
        c_metadata_fsentry_key = rb_define_class_under(c_paludis_module, "MetadataFSPathKey", c_metadata_key);
        rb_define_method(c_metadata_fsentry_key, "parse_value", metadata_fsentry_key_value, 0);

        /*
         * Document-class: Paludis::MetadataTimeKey
         *
         * Metadata class for Time.
         */
        c_metadata_time_key = rb_define_class_under(c_paludis_module, "MetadataTimeKey", c_metadata_key);
        rb_define_method(c_metadata_time_key, "parse_value", metadata_time_key_value, 0);

        /*
         * Document-class: Paludis::MetadataChoicesKey
         *
         * Metadata class for Choices.
         */
        c_metadata_choices_key = rb_define_class_under(c_paludis_module, "MetadataChoicesKey", c_metadata_key);
        rb_define_method(c_metadata_choices_key, "parse_value", metadata_choices_key_value, 0);

        /*
         * Document-class: Paludis::MetadataKeywordNameSetKey
         *
         * Metadata class for keywords.
         */
        c_metadata_keyword_name_set_key = rb_define_class_under(c_paludis_module, "MetadataKeywordNameSetKey", c_metadata_key);
        rb_define_method(c_metadata_keyword_name_set_key, "parse_value", template_methods, 0);

        /*
         * Document-class: Paludis::MetadataPackageIDSequenceKey
         *
         * Metadata class for package IDs.
         */
        c_metadata_package_id_sequence_key = rb_define_class_under(c_paludis_module, "MetadataPackageIDSequenceKey", c_metadata_key);
        rb_define_method(c_metadata_package_id_sequence_key, "parse_value", template_methods, 0);

        /*
         * Document-class: Paludis::MetadataFSPathSequenceKey
         *
         * Metadata class for filesystem sequences.
         */
        c_metadata_fsentry_sequence_key = rb_define_class_under(c_paludis_module, "MetadataFSPathSequenceKey", c_metadata_key);
        rb_define_method(c_metadata_fsentry_sequence_key, "parse_value", template_methods, 0);

        /*
         * Document-class: Paludis::MetadataMaintainersKey
         *
         * Metadata class for maintainers.
         */
        c_metadata_maintainers_key = rb_define_class_under(c_paludis_module, "MetadataMaintainersKey", c_metadata_key);
        rb_define_method(c_metadata_maintainers_key, "parse_value", template_methods, 0);

        /*
         * Document-class: Paludis::MetadataStringSetKey
         *
         * Metadata class for String sets.
         */
        c_metadata_string_set_key = rb_define_class_under(c_paludis_module, "MetadataStringSetKey", c_metadata_key);
        rb_define_method(c_metadata_string_set_key, "parse_value", SetValue<Set<std::string> >::fetch, 0);

        /*
         * Document-class: Paludis::MetadataStringStringMapKey
         *
         * Metadata class for String to String maps.
         */
        c_metadata_string_string_map_key = rb_define_class_under(c_paludis_module, "MetadataStringStringMapKey", c_metadata_key);
        rb_define_method(c_metadata_string_string_map_key, "parse_value", MapValue<Map<std::string, std::string> >::fetch, 0);

        /*
         * Document-class: Paludis::MetadataStringSequenceKey
         *
         * Metadata class for String sequences.
         */
        c_metadata_string_sequence_key = rb_define_class_under(c_paludis_module, "MetadataStringSequenceKey", c_metadata_key);
        rb_define_method(c_metadata_string_sequence_key, "parse_value", SetValue<Sequence<std::string> >::fetch, 0);

        /*
         * Document-class: Paludis::MetadataLicenseSpecTreeKey
         *
         * Metadata class for license specs.
         */
        c_metadata_license_spec_tree_key = rb_define_class_under(c_paludis_module, "MetadataLicenseSpecTreeKey", c_metadata_key);
        rb_define_method(c_metadata_license_spec_tree_key, "parse_value", template_methods, 0);

        /*
         * Document-class: Paludis::MetadataPlainTextSpecTreeKey
         *
         * Metadata class for restrict specs.
         */
        c_metadata_plain_text_spec_tree_key = rb_define_class_under(c_paludis_module, "MetadataPlainTextSpecTreeKey", c_metadata_key);
        rb_define_method(c_metadata_plain_text_spec_tree_key, "parse_value", template_methods, 0);

        /*
         * Document-class: Paludis::MetadataRequiredUseSpecTreeKey
         *
         * Metadata class for restrict specs.
         */
        c_metadata_required_use_spec_tree_key = rb_define_class_under(c_paludis_module, "MetadataRequiredUseSpecTreeKey", c_metadata_key);
        rb_define_method(c_metadata_required_use_spec_tree_key, "parse_value", template_methods, 0);

        /*
         * Document-class: Paludis::MetadataDependencySpecTreeKey
         *
         * Metadata class for dependency specs.
         */
        c_metadata_dependency_spec_tree_key = rb_define_class_under(c_paludis_module, "MetadataDependencySpecTreeKey", c_metadata_key);
        rb_define_method(c_metadata_dependency_spec_tree_key, "parse_value", template_methods, 0);
        rb_define_method(c_metadata_dependency_spec_tree_key, "initial_labels", metadata_dependency_spec_tree_key_initial_labels, 0);

        /*
         * Document-class: Paludis::MetadataFetchableURISpecTreeKey
         *
         * Metadata class for fetchable uri specs.
         */
        c_metadata_fetchable_uri_spec_tree_key = rb_define_class_under(c_paludis_module, "MetadataFetchableURISpecTreeKey", c_metadata_key);
        rb_define_method(c_metadata_fetchable_uri_spec_tree_key, "parse_value", template_methods, 0);
        rb_define_method(c_metadata_fetchable_uri_spec_tree_key, "initial_label", metadata_fetchable_uri_spec_tree_key_initial_label, 0);

        /*
         * Document-class: Paludis::MetadataSimpleURISpecTreeKey
         *
         * Metadata class for simple uri specs.
         */
        c_metadata_simple_uri_spec_tree_key = rb_define_class_under(c_paludis_module, "MetadataSimpleURISpecTreeKey", c_metadata_key);
        rb_define_method(c_metadata_simple_uri_spec_tree_key, "parse_value", template_methods, 0);

        /*
         * Document-class: Paludis::MetadataSectionKey
         *
         * A MetadataSectionKey is a MetadataKey that holds a number of other
         * MetadataKey instances.
         */
        c_metadata_section_key = rb_define_class_under(c_paludis_module, "MetadataSectionKey", c_metadata_key);
        rb_define_method(c_metadata_section_key, "each_metadata", metadata_section_key_each_metadata, 0);
        rb_define_method(c_metadata_section_key, "[]", metadata_section_key_subscript, 1);

        /*
         * Document-module: Paludis::MetadataKeyType
         *
         * The significance of a MetadataKey to a user.
         */
        c_metadata_key_type = rb_define_module_under(c_paludis_module, "MetadataKeyType");
        for (MetadataKeyType l(static_cast<MetadataKeyType>(0)), l_end(last_mkt) ; l != l_end ;
                l = static_cast<MetadataKeyType>(static_cast<int>(l) + 1))
            rb_define_const(c_metadata_key_type, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));

/*
*A key of significant interest, to be shown early on
*/
rb_define_const(c_metadata_key_type, "Significant", 0);
/*
*A normal key, to be shown underneath mkt_significant keys
*/
rb_define_const(c_metadata_key_type, "Normal", 1);
/*
*Should only be shown if the user asks for author information
*/
rb_define_const(c_metadata_key_type, "Author", 2);
/*
*Should only be shown if the user asks for dependencies
*/
rb_define_const(c_metadata_key_type, "Dependencies", 3);
/*
*Should not usually be displayed to the user
*/
rb_define_const(c_metadata_key_type, "Internal", 4);    }
}