aboutsummaryrefslogtreecommitdiffhomepage
path: root/lexlib/PropSetSimple.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'lexlib/PropSetSimple.cxx')
-rw-r--r--lexlib/PropSetSimple.cxx28
1 files changed, 16 insertions, 12 deletions
diff --git a/lexlib/PropSetSimple.cxx b/lexlib/PropSetSimple.cxx
index cbcbac5bd..ba76019be 100644
--- a/lexlib/PropSetSimple.cxx
+++ b/lexlib/PropSetSimple.cxx
@@ -17,27 +17,31 @@
using namespace Scintilla;
+namespace {
+
typedef std::map<std::string, std::string> mapss;
+mapss *PropsFromPointer(void *impl) {
+ return static_cast<mapss *>(impl);
+}
+
+}
+
PropSetSimple::PropSetSimple() {
mapss *props = new mapss;
impl = static_cast<void *>(props);
}
PropSetSimple::~PropSetSimple() {
- mapss *props = static_cast<mapss *>(impl);
+ mapss *props = PropsFromPointer(impl);
delete props;
impl = 0;
}
-void PropSetSimple::Set(const char *key, const char *val, int lenKey, int lenVal) {
- mapss *props = static_cast<mapss *>(impl);
+void PropSetSimple::Set(const char *key, const char *val, size_t lenKey, size_t lenVal) {
+ mapss *props = PropsFromPointer(impl);
if (!*key) // Empty keys are not supported
return;
- if (lenKey == -1)
- lenKey = static_cast<int>(strlen(key));
- if (lenVal == -1)
- lenVal = static_cast<int>(strlen(val));
(*props)[std::string(key, lenKey)] = std::string(val, lenVal);
}
@@ -53,10 +57,10 @@ void PropSetSimple::Set(const char *keyVal) {
endVal++;
const char *eqAt = strchr(keyVal, '=');
if (eqAt) {
- Set(keyVal, eqAt + 1, static_cast<int>(eqAt-keyVal),
- static_cast<int>(endVal - eqAt - 1));
+ Set(keyVal, eqAt + 1, eqAt-keyVal,
+ endVal - eqAt - 1);
} else if (*keyVal) { // No '=' so assume '=1'
- Set(keyVal, "1", static_cast<int>(endVal-keyVal), 1);
+ Set(keyVal, "1", endVal-keyVal, 1);
}
}
@@ -71,7 +75,7 @@ void PropSetSimple::SetMultiple(const char *s) {
}
const char *PropSetSimple::Get(const char *key) const {
- mapss *props = static_cast<mapss *>(impl);
+ mapss *props = PropsFromPointer(impl);
mapss::const_iterator keyPos = props->find(std::string(key));
if (keyPos != props->end()) {
return keyPos->second.c_str();
@@ -86,7 +90,7 @@ const char *PropSetSimple::Get(const char *key) const {
// for that, through a recursive function and a simple chain of pointers.
struct VarChain {
- VarChain(const char *var_=NULL, const VarChain *link_=NULL): var(var_), link(link_) {}
+ VarChain(const char *var_=nullptr, const VarChain *link_= nullptr): var(var_), link(link_) {}
bool contains(const char *testVar) const {
return (var && (0 == strcmp(var, testVar)))