sptk2 logo
SPTK Home Page
PackedStrings.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <sptk5/FieldList.h>
30#include <sptk5/Strings.h>
31
32namespace sptk {
33
42using pchar = char*;
43
47using cpchar = const char*;
48
49
57class SP_EXPORT CPackedStrings
58{
62 uint16_t m_size;
63
67 void* m_buffer;
68
72 void* m_data;
73
74
75public:
81 CPackedStrings(int cnt, const char* strings[]);
82
88 CPackedStrings(FieldList& fields, int keyField);
89
94 explicit CPackedStrings(const Strings& strings);
95
100 CPackedStrings(const CPackedStrings& other) = delete;
101
106
110 uint16_t size() const
111 {
112 return *(uint16_t*) m_buffer;
113 }
114
118 const char* operator[](uint16_t index) const;
119
124
129
133 void user_data(void* d)
134 {
135 m_data = d;
136 }
137
141 void* user_data() const
142 {
143 return m_data;
144 }
145
149 void argument(int32_t arg)
150 {
151 m_data = (void*) (uint64_t) arg;
152 }
153
157 int32_t argument() const
158 {
159 return (int32_t) (uint64_t) m_data;
160 }
161
165 unsigned char height;
166
170 unsigned char flags;
171};
175} // namespace sptk
Packed strings list.
Definition: PackedStrings.h:58
CPackedStrings(int cnt, const char *strings[])
void argument(int32_t arg)
Definition: PackedStrings.h:149
CPackedStrings(FieldList &fields, int keyField)
unsigned char height
Definition: PackedStrings.h:165
const char * operator[](uint16_t index) const
CPackedStrings & operator=(const CPackedStrings &)
void * user_data() const
Definition: PackedStrings.h:141
unsigned char flags
Definition: PackedStrings.h:170
uint16_t size() const
Definition: PackedStrings.h:110
CPackedStrings(const Strings &strings)
CPackedStrings & operator=(const Strings &)
CPackedStrings(const CPackedStrings &other)=delete
void user_data(void *d)
Definition: PackedStrings.h:133
int32_t argument() const
Definition: PackedStrings.h:157
Definition: FieldList.h:50
Definition: Strings.h:52
const char * cpchar
Definition: PackedStrings.h:47
char * pchar
Definition: PackedStrings.h:42

Fri Oct 14 2022 09:58:32: SPTK 5.4.1