SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
KeySeq.cc
Go to the documentation of this file.
1 /*
2  * SWC-DB© Copyright since 2019 Alex Kashirin <kashirin.alex@gmail.com>
3  * License details at <https://github.com/kashirin-alex/swc-db/#license>
4  */
5 
6 
7 
9 
10 
11 namespace SWC { namespace DB { namespace Types {
12 
13 
14 namespace {
15  const char KeySeq_LEXIC[] = "LEXIC";
16  const char KeySeq_VOLUME[] = "VOLUME";
17  const char KeySeq_FC_LEXIC[] = "FC_LEXIC";
18  const char KeySeq_FC_VOLUME[] = "FC_VOLUME";
19  const char KeySeq_UNKNOWN[] = "UNKNOWN";
20 }
21 
22 bool is_fc(KeySeq typ) noexcept {
23  switch(typ) {
24  case KeySeq::FC_LEXIC:
25  case KeySeq::FC_VOLUME:
26  return true;
27  default:
28  return false;
29  }
30 }
31 
32 
33 const char* to_string(KeySeq typ) noexcept {
34  switch(typ) {
35  case KeySeq::LEXIC:
36  return KeySeq_LEXIC;
37  case KeySeq::VOLUME:
38  return KeySeq_VOLUME;
39  case KeySeq::FC_LEXIC:
40  return KeySeq_FC_LEXIC;
41  case KeySeq::FC_VOLUME:
42  return KeySeq_FC_VOLUME;
43  default:
44  return KeySeq_UNKNOWN;
45  }
46 }
47 
48 KeySeq range_seq_from(const std::string& typ) noexcept {
49  switch(typ.length()) {
50  case 1: {
51  switch(*typ.data()) {
52  case '1':
53  return KeySeq::LEXIC;
54  case '2':
55  return KeySeq::VOLUME;
56  case '3':
57  return KeySeq::FC_LEXIC;
58  case '4':
59  return KeySeq::FC_VOLUME;
60  default:
61  break;
62  }
63  break;
64  }
65  case 5: {
66  if(Condition::str_case_eq(typ.data(), KeySeq_LEXIC, 5))
67  return KeySeq::LEXIC;
68  break;
69  }
70  case 6: {
71  if(Condition::str_case_eq(typ.data(), KeySeq_VOLUME, 6))
72  return KeySeq::VOLUME;
73  break;
74  }
75  case 8: {
76  if(Condition::str_case_eq(typ.data(), KeySeq_FC_LEXIC, 8))
77  return KeySeq::FC_LEXIC;
78  break;
79  }
80  case 9: {
81  if(Condition::str_case_eq(typ.data(), KeySeq_FC_VOLUME, 9))
82  return KeySeq::FC_VOLUME;
83  break;
84  }
85  default:
86  break;
87  }
88  return KeySeq::UNKNOWN;
89 }
90 
91 
92 }}}
SWC::DB::Types::is_fc
bool SWC_CONST_FUNC is_fc(KeySeq typ) noexcept
Definition: KeySeq.cc:22
KeySeq.h
SWC::DB::Types::to_string
const char *SWC_CONST_FUNC to_string(Column typ) noexcept
Definition: Column.cc:38
SWC::DB::Types::range_seq_from
KeySeq SWC_PURE_FUNC range_seq_from(const std::string &typ) noexcept
Definition: KeySeq.cc:48
SWC::DB::Types::KeySeq
KeySeq
Definition: KeySeq.h:13
SWC::DB::Types::KeySeq::UNKNOWN
@ UNKNOWN
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::Condition::str_case_eq
bool str_case_eq(const char *s1, const char *s2, size_t count) noexcept SWC_ATTRIBS((SWC_ATTRIB_O3))
Definition: Comparators_basic.h:257