68    cout << VERSION << 
"\n";
 
 
   78        "Usage: kea-msg-compiler [-h] [-v] [-d dir] <message-file>\n" <<
 
   80        "-h       Print this message and exit\n" <<
 
   81        "-v       Print the program version and exit\n" <<
 
   82        "-d <dir> Place output files in given directory\n" <<
 
   84        "<message-file> is the name of the input message file.\n";
 
 
   99    string name = 
file.stem();
 
  100    string ext = 
file.extension();
 
  101    string sentinel_text = name + 
"_" + ext.substr(1);
 
  103    return (sentinel_text);
 
 
  119    outstring.reserve(instring.size());
 
  122    for (
size_t i = 0; i < instring.size(); ++i) {
 
  123        if (instring[i] == 
'"') {
 
  126        outstring += instring[i];
 
 
  143    vector<string> ident;
 
  145    for (
auto const& i : dictionary) {
 
  146        ident.push_back(i.first);
 
  148    sort(ident.begin(), ident.end());
 
 
  173    while ((dcolon = ns.find(
"::")) != string::npos) {
 
  174        ns.replace(dcolon, 2, 
":");
 
 
  190        for (vector<string>::size_type i = 0; i < ns.size(); ++i) {
 
  191            output << 
"namespace " << ns[i] << 
" {\n";
 
 
  203        for (
int i = ns.size() - 1; i >= 0; --i) {
 
  204            output << 
"} // namespace " << ns[i] << 
"\n";
 
 
  227                const vector<string>& ns_components,
 
  229                const char* output_directory) {
 
  232    if (output_directory != NULL) {
 
  237    string sentinel_text = 
sentinel(header_file);
 
  243    ofstream hfile(header_file.
str());
 
  255        "// File created from " << message_file.
str() << 
"\n" <<
 
  257         "#ifndef " << sentinel_text << 
"\n" <<
 
  258         "#define "  << sentinel_text << 
"\n" <<
 
  260         "#include <log/message_types.h>\n" <<
 
  267    for (
auto const& j : idents) {
 
  268        hfile << 
"extern const isc::log::MessageID " << j << 
";\n";
 
  275    hfile << 
"#endif // " << sentinel_text << 
"\n";
 
 
  292    return (isalnum(c) ? c : 
'_');
 
 
  330                 const vector<string>& ns_components,
 
  332                 const char* output_directory) {
 
  335    if (output_directory) {
 
  343    ofstream ccfile(program_file.
str());
 
  355        "// File created from " << message_file.
str() << 
"\n" <<
 
  357         "#include <cstddef>\n" <<
 
  358         "#include <log/message_types.h>\n" <<
 
  359         "#include <log/message_initializer.h>\n" <<
 
  367    for (
auto const& j : idents) {
 
  368        ccfile << 
"extern const isc::log::MessageID " << j <<
 
  369            " = \"" << j << 
"\";\n";
 
  380         "const char* values[] = {\n";
 
  384    for (
auto const& i : idents) {
 
  393        "const isc::log::MessageInitializer initializer(values);\n" <<
 
  395        "} // Anonymous namespace\n" <<
 
 
  421    if (!duplicates.empty()) {
 
  422        cout << 
"Error: the following duplicate IDs were found:\n";
 
  424        sort(duplicates.begin(), duplicates.end());
 
  425        MessageReader::MessageIDCollection::iterator new_end =
 
  426            unique(duplicates.begin(), duplicates.end());
 
  427        duplicates.erase(new_end, duplicates.end());
 
  428        for (
auto const& i : duplicates) {
 
  429            cout << 
"    " << i << 
"\n";
 
 
  442    const char* soptions = 
"hvpd:";               
 
  447    const char *output_directory = NULL;
 
  449    while ((opt = getopt(argc, argv, soptions)) != -1) {
 
  452                output_directory = optarg;
 
  470    if (optind < (argc - 1)) {
 
  471        cout << 
"Error: excess arguments in command line\n";
 
  474    } 
else if (optind >= argc) {
 
  475        cout << 
"Error: missing message file\n";
 
  479    string message_file = argv[optind];
 
  495        vector<string> ns_components =
 
  509        string text = e.
id();
 
  511        text += global->getText(e.
id());
 
  514        for (
size_t i(0); i < args.size(); ++ i) {
 
  522        cerr << text << 
"\n";
 
  525    } 
catch (
const std::exception& ex) {
 
  526        cerr << 
"Fatal error: " << ex.what() << 
"\n";
 
  530        cerr << 
"Fatal error\n";
 
 
static const MessageDictionaryPtr & globalDictionary()
Return Global Dictionary.
virtual const std::string & getText(const MessageID &ident) const
Get Message Text.
std::vector< std::string > arguments() const
Return Arguments.
MessageID id() const
Return Message ID.
std::vector< std::string > MessageIDCollection
Visible collection types.
MessageIDCollection getNotAdded() const
Get Not-Added List.
virtual std::string getNamespace() const
Get Namespace.
virtual void readFile(const std::string &file, Mode mode=ADD)
Read File.
#define isc_throw_4(type, stream, param1, param2, param3, param4)
Similar as isc_throw, but allows the exception to have four additional parameters (the stream/text go...
void writeHeaderFile(const string &file, const vector< string > &ns_components, MessageDictionary &dictionary, const char *output_directory)
Write Header File.
int main(int argc, char *argv[])
Main Program.
char replaceNonAlphaNum(char c)
Convert Non Alpha-Numeric Characters to Underscores.
vector< string > splitNamespace(string ns)
Split Namespace.
void writeClosingNamespace(ostream &output, const vector< string > &ns)
Write Closing Namespace(s)
void writeProgramFile(const string &file, const vector< string > &ns_components, MessageDictionary &dictionary, const char *output_directory)
Write Program File.
void writeOpeningNamespace(ostream &output, const vector< string > &ns)
Write Opening Namespace(s)
void version()
Print Version.
string quoteString(const string &instring)
Quote String.
vector< string > sortedIdentifiers(MessageDictionary &dictionary)
Sorted Identifiers.
string sentinel(Path &file)
Create Header Sentinel.
void errorDuplicates(MessageReader &reader)
Error and exit if there are duplicate entries.
const isc::log::MessageID LOG_OPEN_OUTPUT_FAIL
void replacePlaceholder(std::string &message, const string &arg, const unsigned placeholder)
The internal replacement routine.
boost::shared_ptr< MessageDictionary > MessageDictionaryPtr
Shared pointer to the MessageDictionary.
const isc::log::MessageID LOG_WRITE_ERROR
vector< string > tokens(const string &text, const string &delim, bool escape)
Split string into tokens.
void uppercase(string &text)
Convert string to uppercase.
Path & replaceParentPath(std::string const &replacement=std::string())
Trims {replacement} and replaces this instance's parent path with it.
std::string str() const
Get the path in textual format.