コード例 #1
0
ファイル: views.cpp プロジェクト: ikhramts/isaword
/**
 * Initialize.
 * Returns true if there were no problems; false if the initialization
 * failed.
 */
bool PageHandler::initialize(const std::string& resource_root) {
    template_cache_ = boost::shared_ptr<FileCache>(new FileCache(resource_root));
    page_buffer_ = shared_array<char>(new char[page_buffer_size_]);
    
    // Create the descriptions of lists of words to keep track of.
    shared_ptr<WordIndexDescription> j_words(
        new WordIndexDescription("j_words", "J words", "^.*J.*$"));
    shared_ptr<WordIndexDescription> q_words(
        new WordIndexDescription("q_words", "Q words", ".*Q.*"));
    shared_ptr<WordIndexDescription> q_witout_u_words(
        new WordIndexDescription("q_withoutt_u_words", "Q without U words", "^(.*Q[^U].*)|(.*Q)$"));
    shared_ptr<WordIndexDescription> x_words(
        new WordIndexDescription("x_words", "X words", "^.*X.*$"));
    shared_ptr<WordIndexDescription> z_words(
        new WordIndexDescription("z_words", "Z words", "^.*Z.*$"));
    shared_ptr<WordIndexDescription> consonants(
        new WordIndexDescription("consonants", "Consonants Only", "^[^AEIOU]*$"));
    shared_ptr<WordIndexDescription> all_vowels_but_one(
        new WordIndexDescription("all_vowels_but_one", "All vowels but one", "^[AEIOU]*[^AEIOU][AEIOU]*$"));
    shared_ptr<WordIndexDescription> out_words(
        new WordIndexDescription("out_words", "OUT- words", "^OUT.*$"));
    shared_ptr<WordIndexDescription> re_words(
        new WordIndexDescription("re_words", "RE- words", "^RE.*$"));
    
    index_descriptions_.push_back(j_words);
    index_descriptions_.push_back(q_words);
    index_descriptions_.push_back(q_witout_u_words);
    index_descriptions_.push_back(x_words);
    index_descriptions_.push_back(z_words);
    index_descriptions_.push_back(consonants);
    index_descriptions_.push_back(all_vowels_but_one);
    index_descriptions_.push_back(out_words);
    index_descriptions_.push_back(re_words);
    
    //Create the word picker.
    word_picker_ = shared_ptr<WordPicker>(new WordPicker(index_descriptions_));
    bool has_initialized_word_picker = 
        word_picker_->initialize(resource_root + "dictionaries/owl2.txt");
    
    //Build vairous templates.
    main_page_template_ =  this->build_main_page_template();
    about_page_ = this->insert_into_main_layout("templates/about.html");
    fine_print_page_ = this->insert_into_main_layout("templates/fine-print.html");
    not_found_template_ = this->insert_into_main_layout("templates/404.html");
    
    //Attach to the server.
    server_->add_url_handler("/", &main_page, (void*) this);
    server_->add_url_handler("/about/?", &about, (void*) this);
    server_->add_url_handler("/fine_print/?", &fine_print, (void*) this);
    server_->add_url_handler("/words/[a-z0-9/_]+", &words, (void*) this);
    server_->set_not_found_handler(&not_found, this);
    return has_initialized_word_picker;
}
コード例 #2
0
void mt_substitute_search::create_system_digits_configuration()
{
	single_substitute_digits_configuration.digitsConsonantsSetMap.clear();
  std::string consonants("ZSTDN M R L J KGFWPB");
  for (int i = 0; i < 10; i++) {
      std::string temp(consonants);
      temp.erase(i * 2, 2);
      ConsonantsForDigit cons_set                                   = {consonants.substr(i * 2, 2), temp};
      single_substitute_digits_configuration.digitsConsonantsSetMap[i] = cons_set;
  }
  single_substitute_digits_configuration.allConsonants="ZSTDNMRLJKGFWPB";
}