Skip to content

Commit bb5962b

Browse files
committed
Remove PUBLIC_API from mysqlx::string and other basic types.
Note: These types are implemented entirely in public headers, so this should be OK.
1 parent 22cccd7 commit bb5962b

File tree

7 files changed

+95
-20
lines changed

7 files changed

+95
-20
lines changed

devapi/collection_crud.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ class Op_collection_modify
550550

551551
void process(Update_spec::Processor &prc) const override
552552
{
553-
Doc_field_parser doc_field(m_update_it->m_field);
553+
Doc_field_parser doc_field((mysqlx::string)m_update_it->m_field);
554554

555555
switch (m_update_it->m_op)
556556
{

devapi/impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class Value_expr
204204
for (Field fld : doc)
205205
{
206206
Value_expr value(doc[fld], m_is_expr, m_parser_mode);
207-
value.process_if(dprc->key_val(fld));
207+
value.process_if(dprc->key_val((string)fld));
208208
}
209209
dprc->doc_end();
210210
}

devapi/session.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,8 @@ SqlStatement& NodeSession::sql(const string &query)
11271127
// ---------------------------------------------------------------------
11281128

11291129

1130+
#if 0
1131+
11301132
string::string(const std::string &other)
11311133
: std::wstring(cdk::string(other))
11321134
{}
@@ -1142,6 +1144,20 @@ string::operator std::string() const
11421144
return std::string(cdk::string(*this));
11431145
}
11441146

1147+
#endif
1148+
1149+
1150+
std::string string::Impl::to_utf8(const string &other)
1151+
{
1152+
return cdk::string(other);
1153+
}
1154+
1155+
void string::Impl::from_utf8(string &s, const std::string &other)
1156+
{
1157+
s = cdk::string(other);
1158+
}
1159+
1160+
11451161
/*
11461162
string::operator const cdk::foundation::string&() const
11471163
{

include/devapi/common.h

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,15 @@ struct List_init
9393
Currently only utf-8 encoding is supported.
9494
*/
9595

96-
DLL_WARNINGS_PUSH
97-
98-
class PUBLIC_API string : public std::wstring
96+
class string : public std::wstring
9997
{
98+
99+
struct Impl
100+
{
101+
PUBLIC_API static std::string to_utf8(const string&);
102+
PUBLIC_API static void from_utf8(string&, const std::string&);
103+
};
104+
100105
public:
101106

102107
string() {}
@@ -117,15 +122,27 @@ class PUBLIC_API string : public std::wstring
117122

118123
// TODO: make utf8 conversions explicit
119124

120-
string(const char*);
121-
string(const std::string&);
125+
string(const char *other)
126+
{
127+
if (!other)
128+
return;
129+
std::string utf8(other);
130+
Impl::from_utf8(*this, utf8);
131+
}
122132

123-
// operator cdk::foundation::string&();
124-
operator std::string() const; // conversion to utf-8
125-
// operator const cdk::foundation::string&() const;
126-
};
133+
string(const std::string &other)
134+
{
135+
Impl::from_utf8(*this, other);
136+
}
127137

128-
DLL_WARNINGS_POP
138+
// conversion to utf-8
139+
140+
operator std::string() const
141+
{
142+
return Impl::to_utf8(*this);
143+
}
144+
145+
};
129146

130147

131148
inline
@@ -161,7 +178,7 @@ typedef unsigned long row_count_t;
161178
bytes buf = std::get_temporary_buffer<byte>(size);
162179
*/
163180

164-
class PUBLIC_API bytes : public std::pair<byte*, size_t>
181+
class bytes : public std::pair<byte*, size_t>
165182
{
166183

167184
public:
@@ -200,7 +217,7 @@ class PUBLIC_API bytes : public std::pair<byte*, size_t>
200217

201218
namespace internal {
202219

203-
class PUBLIC_API nocopy
220+
class nocopy
204221
{
205222
public:
206223
nocopy(const nocopy&) = delete;

include/devapi/document.h

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,46 @@ class DocResult;
5757
TODO: _fld suffix
5858
*/
5959

60-
class PUBLIC_API Field : public string
60+
class PUBLIC_API Field
6161
{
62+
DLL_WARNINGS_PUSH
63+
string m_fld;
64+
DLL_WARNINGS_POP
65+
6266
public:
6367

64-
Field(const string &s) : string(s)
68+
Field(const string &s) : m_fld(s)
6569
{}
6670

6771
// TODO: is it auto generated?
68-
Field(string &&s) : string(std::move(s))
72+
Field(string &&s) : m_fld(std::move(s))
6973
{}
7074

71-
Field(const char *s) : string(s)
75+
Field(const char *s) : m_fld(s)
7276
{}
7377

78+
operator const string&() const { return m_fld; }
79+
80+
bool operator <(const Field &other) const
81+
{
82+
return m_fld < other.m_fld;
83+
}
84+
85+
bool operator >(const Field &other) const
86+
{
87+
return m_fld > other.m_fld;
88+
}
89+
90+
bool operator ==(const Field &other) const
91+
{
92+
return m_fld == other.m_fld;
93+
}
94+
95+
bool operator !=(const Field &other) const
96+
{
97+
return m_fld != other.m_fld;
98+
}
99+
74100
};
75101

76102

@@ -407,11 +433,11 @@ class PUBLIC_API Value : public internal::Printable
407433

408434
typedef std::vector<Value> Array;
409435

410-
bytes m_raw;
411-
string m_str;
412436
DbDoc m_doc;
413437

414438
DLL_WARNINGS_PUSH
439+
bytes m_raw;
440+
string m_str;
415441
std::shared_ptr<Array> m_arr;
416442
DLL_WARNINGS_POP
417443

include/devapi/result.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,10 @@ class PUBLIC_API Warning : public internal::Printable
222222

223223
Level m_level;
224224
uint16_t m_code;
225+
226+
DLL_WARNINGS_PUSH
225227
string m_msg;
228+
DLL_WARNINGS_POP
226229

227230
Warning(Level level, uint16_t code, const string &msg)
228231
: m_level(level), m_code(code), m_msg(msg)
@@ -272,8 +275,13 @@ namespace internal {
272275

273276
class XSession_base;
274277

278+
DLL_WARNINGS_PUSH
279+
275280
class PUBLIC_API BaseResult : nocopy
276281
{
282+
283+
DLL_WARNINGS_PUSH
284+
277285
class INTERNAL Impl;
278286
Impl *m_impl = NULL;
279287
bool m_owns_impl = false;

include/mysql_devapi.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ class PUBLIC_API DatabaseObject
7777
protected:
7878

7979
internal::XSession_base *m_sess;
80+
81+
DLL_WARNINGS_PUSH
8082
string m_name;
83+
DLL_WARNINGS_POP
8184

8285
DatabaseObject(internal::XSession_base& sess, const string& name = string())
8386
: m_sess(&sess), m_name(name)
@@ -499,8 +502,13 @@ namespace internal {
499502
@todo Add all `XSession` methods defined by DevAPI.
500503
*/
501504

505+
DLL_WARNINGS_PUSH
506+
502507
class PUBLIC_API XSession_base : nocopy
503508
{
509+
510+
DLL_WARNINGS_POP
511+
504512
protected:
505513

506514
class INTERNAL Impl;

0 commit comments

Comments
 (0)