Code:
//STL Modules:
#include <string>
#include <vector>
//My modules:
#include "modules/C_html4_attributes/C_html4_attributes.h"
#include "C_ENUM_tag_converted_to_strings.h"
namespace N_init_class_members {
typedef std::vector<S_html_attr_value> TYPE_attr_values;
void initAttr(C_html4_attributes::ENUM_attr attr_ET, S_html_attr& attr, const std::string& desc, const std::vector<S_browser>& supportedBrowsers,
const std::map<S_browser, TYPE_attr_values>& supportedAttrValues, bool required, bool deprecated,
const std::vector<std::string>& notes, const std::vector<std::string>& tips);
void initSingleTag(S_html_tag& singleTag, const char* tagName, const std::vector<S_html_attr>& supportedAttrs);
void initStartTag(S_html_tag& startTag, const char* tagName, const std::vector<S_html_attr>& supportedAttrs);
void initEndTag(S_html_tag& endTag, const char* tagName);
}
class C_html4_tags {
public:
friend void N_init_class_members::initAttr(C_html4_attributes::ENUM_attr attr_ET, S_html_attr& attr, const std::string& desc, const std::vector<S_browser>& supportedBrowsers,
const std::map<S_browser, N_init_class_members::TYPE_attr_values>& supportedAttrValues, bool required, bool deprecated,
const std::vector<std::string>& notes, const std::vector<std::string>& tips);
private:
C_html4_attributes C_html4_attributes_obj;
};
void N_init_class_members::initAttr(C_html4_attributes::ENUM_attr attr_ET, S_html_attr& attr, const std::string& desc, const std::vector<S_browser>& supportedBrowsers,
const std::map<S_browser, N_init_class_members::TYPE_attr_values>& supportedAttrValues, bool required, bool deprecated,
const std::vector<std::string>& notes, const std::vector<std::string>& tips) {
try {
C_html4_attributes_obj.setDescOfAttr(attr_ET, desc);
C_html4_attributes_obj.setSupportedBrowsersOfAttr(attr_ET, supportedBrowsers);
C_html4_attributes_obj.setSupportedAttrValuesOfAttr(attr_ET, supportedAttrValues);
C_html4_attributes_obj.setRequiredOfAttr(attr_ET, required);
C_html4_attributes_obj.setDeprecatedOfAttr(attr_ET, deprecated);
C_html4_attributes_obj.setNotesOfAttr(attr_ET, notes);
C_html4_attributes_obj.setTipsOfAttr(attr_ET, tips);
attr = C_html4_attributes_obj.getAttr(attr_ET);
}
catch (const char* exc) {
C_ENUM_attr_converted_to_strings enum_conversion_obj;
int attr_enumerator_value = attr_ET;
std::string attr_enumerator_name;
attr_enumerator_name = enum_conversion_obj.getNameOfEnumerator(enum_conversion_obj.castIntToEnumerator<C_ENUM_attr_converted_to_strings::ENUM_attr>(attr_enumerator_value));
std::string exc_str = "Error! Call to N_init_class_members::initAttr().\n"
"You passed to parameter 1, 'attr_ET', the attribute\n"
"type name '" + attr_enumerator_name + "', so that\n"
"is the attribute which you failed to initialize.\n"
"This function has called several different member\n"
"functions of a C_html4_attributes class object.\n"
"One of these reported the following exception:\n\n";
exc_str += exc;
throw (exc_str.c_str()); //re-throw exception
}
}
As you can see, I declared the namespace function "N_init_class_members::initAttr()" as a friend in the C_html4_tags class, and yet, the compiler still says that the "C_html4_attributes_obj" (which is a private member of C_html4_tags) "was not declared in this scope".