]> git.donarmstrong.com Git - lilypond.git/blob - lily/keyword.cc
Issue 4550 (2/2) Avoid "using namespace std;" in included files
[lilypond.git] / lily / keyword.cc
1 /*
2   keyword.cc -- keywords and identifiers
3 */
4
5 #include "keyword.hh"
6
7 #include <cstring>
8 #include <cstdlib>
9
10 /* for qsort */
11 bool tab_less (Keyword_ent const &p1, Keyword_ent const &p2)
12 {
13   return strcmp (p1.name_, p2.name_) < 0;
14 }
15
16 Keyword_table::Keyword_table (Keyword_ent *tab)
17 {
18   while (tab->name_)
19     table_.push_back (*tab++);
20
21   vector_sort (table_, tab_less);
22 }
23
24 vsize
25 Keyword_table::lookup (char const *s) const
26 {
27   Keyword_ent e;
28   e.name_ = s;
29   vsize idx = binary_search (table_, e, tab_less);
30   if (idx != VPOS)
31     return table_[idx].tokcode_;
32   return VPOS;
33 }