Browse Source

Added isNotEmpty() to Readable_String.

Modified instances of size() == 0 and size() != 0 to isEmpty() and isNotEmpty(), as appropriate.
release/0.19
JustinAJ 10 years ago
parent
commit
75185185f1
  1. 10
      Jupiter/File.cpp
  2. 43
      Jupiter/INIFile.cpp
  3. 95
      Jupiter/IRC_Client.cpp
  4. 7
      Jupiter/Readable_String.h
  5. 36
      Jupiter/Readable_String_Imp.h
  6. 3
      Jupiter/SecureSocket.cpp
  7. 2
      Jupiter/String_Type_Imp.h
  8. BIN
      Release/Jupiter.lib

10
Jupiter/File.cpp

@ -110,7 +110,7 @@ bool Jupiter::File::load(const char *file)
{
FILE *filePtr = fopen(file, "rb");
if (filePtr == nullptr) return false;
if (Jupiter::File::data_->fileName.size() == 0)
if (Jupiter::File::data_->fileName.isEmpty())
Jupiter::File::data_->fileName = file;
bool r = Jupiter::File::load(filePtr);
fclose(filePtr);
@ -122,7 +122,7 @@ bool Jupiter::File::load(const Jupiter::ReadableString &file)
Jupiter::CStringS fileName = file;
FILE *filePtr = fopen(fileName.c_str(), "rb");
if (filePtr == nullptr) return false;
if (Jupiter::File::data_->fileName.size() == 0)
if (Jupiter::File::data_->fileName.isEmpty())
Jupiter::File::data_->fileName = file;
bool r = Jupiter::File::load(filePtr);
fclose(filePtr);
@ -178,7 +178,8 @@ void Jupiter::File::unload()
bool Jupiter::File::reload()
{
if (Jupiter::File::data_->fileName.size() == 0) return false;
if (Jupiter::File::data_->fileName.isEmpty())
return false;
Jupiter::CStringS fileName(std::move(Jupiter::File::data_->fileName));
Jupiter::File::unload();
return Jupiter::File::load(fileName.c_str());
@ -204,7 +205,8 @@ bool Jupiter::File::reload(FILE *file)
bool Jupiter::File::sync()
{
if (Jupiter::File::data_->fileName.size() == 0) return false;
if (Jupiter::File::data_->fileName.isEmpty())
return false;
return Jupiter::File::sync(Jupiter::File::data_->fileName.c_str());
}

43
Jupiter/INIFile.cpp

@ -144,7 +144,7 @@ const Jupiter::ReadableString &Jupiter::INIFile::Section::get(const Jupiter::Rea
bool Jupiter::INIFile::Section::getBool(const Jupiter::ReadableString &key, bool defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::INIFile::Section::get(key);
if (val.isEmpty() == false)
if (val.isNotEmpty())
return val.asBool();
return defaultValue;
}
@ -157,7 +157,7 @@ short Jupiter::INIFile::Section::getShort(const Jupiter::ReadableString &key, sh
int Jupiter::INIFile::Section::getInt(const Jupiter::ReadableString &key, int defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::INIFile::Section::get(key);
if (val.isEmpty() == false)
if (val.isNotEmpty())
return val.asInt();
return defaultValue;
}
@ -165,7 +165,7 @@ int Jupiter::INIFile::Section::getInt(const Jupiter::ReadableString &key, int de
long Jupiter::INIFile::Section::getLong(const Jupiter::ReadableString &key, long defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::INIFile::Section::get(key);
if (val.isEmpty() == false)
if (val.isNotEmpty())
return val.asInt();
return defaultValue;
}
@ -173,7 +173,7 @@ long Jupiter::INIFile::Section::getLong(const Jupiter::ReadableString &key, long
long long Jupiter::INIFile::Section::getLongLong(const Jupiter::ReadableString &key, long long defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::INIFile::Section::get(key);
if (val.isEmpty() == false)
if (val.isNotEmpty())
return val.asLongLong();
return defaultValue;
}
@ -181,7 +181,7 @@ long long Jupiter::INIFile::Section::getLongLong(const Jupiter::ReadableString &
float Jupiter::INIFile::Section::getFloat(const Jupiter::ReadableString &key, float defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::INIFile::Section::get(key);
if (val.isEmpty() == false)
if (val.isNotEmpty())
return float(val.asDouble());
return defaultValue;
}
@ -189,7 +189,7 @@ float Jupiter::INIFile::Section::getFloat(const Jupiter::ReadableString &key, fl
double Jupiter::INIFile::Section::getDouble(const Jupiter::ReadableString &key, double defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::INIFile::Section::get(key);
if (val.isEmpty() == false)
if (val.isNotEmpty())
return val.asDouble();
return defaultValue;
}
@ -197,7 +197,7 @@ double Jupiter::INIFile::Section::getDouble(const Jupiter::ReadableString &key,
long double Jupiter::INIFile::Section::getLongDouble(const Jupiter::ReadableString &key, long double defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::INIFile::Section::get(key);
if (val.isEmpty() == false)
if (val.isNotEmpty())
return val.asDouble();
return defaultValue;
}
@ -338,11 +338,11 @@ unsigned int Jupiter::INIFile::readFile(const char *fileName)
line = file.getLine(index);
// check if line is a comment.
while (line.size() != 0 && isspace(line.get(0)))
while (line.isNotEmpty() && isspace(line.get(0)))
line.shiftRight(1);
if (line.size() == 0) continue; // Completely whitespace.
if (line.get(0) == ';') continue; // Comment.
if (line.isEmpty() || line.get(0) == ';')
continue;
while (isspace(line.get(line.size() - 1))) // This is safe due to the previous check, which confirms that there is a non-whitespace character.
line.truncate(1);
@ -352,7 +352,7 @@ unsigned int Jupiter::INIFile::readFile(const char *fileName)
line.shiftRight(1);
// Truncate up to the last ']'.
while (line.size() != 0 && line.get(line.size() - 1) != ']')
while (line.isNotEmpty() && line.get(line.size() - 1) != ']')
line.truncate(1);
line.truncate(1); // Truncate the ']' we stoped at.
@ -362,10 +362,10 @@ unsigned int Jupiter::INIFile::readFile(const char *fileName)
{
Jupiter::ReferenceString key = line.getWord(0, "=");
Jupiter::ReferenceString value = line.substring(key.size() + 1);
while (key.size() != 0 && isspace(key.get(key.size() - 1)))
while (key.isNotEmpty() && isspace(key.get(key.size() - 1)))
key.truncate(1);
while (value.size() != 0 && isspace(value.get(0)))
while (value.isNotEmpty() && isspace(value.get(0)))
value.shiftRight(1);
if (Jupiter::INIFile::set(section, key, value))
@ -424,7 +424,8 @@ bool Jupiter::INIFile::sync(const Jupiter::ReadableString &file)
bool Jupiter::INIFile::sync()
{
if (Jupiter::INIFile::data_->fName.size() == 0) return false;
if (Jupiter::INIFile::data_->fName.isEmpty())
return false;
return Jupiter::INIFile::sync(Jupiter::INIFile::data_->fName.c_str());
}
@ -576,7 +577,7 @@ const Jupiter::ReadableString &Jupiter::INIFile::get(const Jupiter::ReadableStri
bool Jupiter::INIFile::getBool(const Jupiter::ReadableString &section, const Jupiter::ReadableString &key, bool defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::INIFile::get(section, key);
if (val.isEmpty() == false)
if (val.isNotEmpty())
return val.asBool();
return defaultValue;
}
@ -589,7 +590,7 @@ short Jupiter::INIFile::getShort(const Jupiter::ReadableString &section, const J
int Jupiter::INIFile::getInt(const Jupiter::ReadableString &section, const Jupiter::ReadableString &key, int defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::INIFile::get(section, key);
if (val.isEmpty() == false)
if (val.isNotEmpty())
return val.asInt();
return defaultValue;
}
@ -597,7 +598,7 @@ int Jupiter::INIFile::getInt(const Jupiter::ReadableString &section, const Jupit
long Jupiter::INIFile::getLong(const Jupiter::ReadableString &section, const Jupiter::ReadableString &key, long defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::INIFile::get(section, key);
if (val.isEmpty() == false)
if (val.isNotEmpty())
return val.asInt();
return defaultValue;
}
@ -605,7 +606,7 @@ long Jupiter::INIFile::getLong(const Jupiter::ReadableString &section, const Jup
long long Jupiter::INIFile::getLongLong(const Jupiter::ReadableString &section, const Jupiter::ReadableString &key, long long defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::INIFile::get(section, key);
if (val.isEmpty() == false)
if (val.isNotEmpty())
return val.asLongLong();
return defaultValue;
}
@ -613,7 +614,7 @@ long long Jupiter::INIFile::getLongLong(const Jupiter::ReadableString &section,
float Jupiter::INIFile::getFloat(const Jupiter::ReadableString &section, const Jupiter::ReadableString &key, float defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::INIFile::get(section, key);
if (val.isEmpty() == false)
if (val.isNotEmpty())
return float(val.asDouble());
return defaultValue;
}
@ -621,7 +622,7 @@ float Jupiter::INIFile::getFloat(const Jupiter::ReadableString &section, const J
double Jupiter::INIFile::getDouble(const Jupiter::ReadableString &section, const Jupiter::ReadableString &key, double defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::INIFile::get(section, key);
if (val.isEmpty() == false)
if (val.isNotEmpty())
return val.asDouble();
return defaultValue;
}
@ -629,7 +630,7 @@ double Jupiter::INIFile::getDouble(const Jupiter::ReadableString &section, const
long double Jupiter::INIFile::getLongDouble(const Jupiter::ReadableString &section, const Jupiter::ReadableString &key, long double defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::INIFile::get(section, key);
if (val.isEmpty() == false)
if (val.isNotEmpty())
return val.asDouble();
return defaultValue;
}

95
Jupiter/IRC_Client.cpp

@ -131,22 +131,26 @@ Jupiter::IRC::Client::Client(const Jupiter::ReadableString &configSection)
Jupiter::IRC::Client::data_->realName = Jupiter::IRC::Client::readConfigValue(STRING_LITERAL_AS_REFERENCE("Realname"), STRING_LITERAL_AS_REFERENCE("Jupiter IRC Client"));
Jupiter::IRC::Client::data_->saslPass = Jupiter::IRC::Client::readConfigValue(STRING_LITERAL_AS_REFERENCE("SASL.Password"));
if (Jupiter::IRC::Client::data_->saslPass.size() == 0) Jupiter::IRC::Client::data_->saslPass = Jupiter::IRC::Client::readConfigValue(STRING_LITERAL_AS_REFERENCE("SASL.Pass"));
if (Jupiter::IRC::Client::data_->saslPass.isEmpty())
Jupiter::IRC::Client::data_->saslPass = Jupiter::IRC::Client::readConfigValue(STRING_LITERAL_AS_REFERENCE("SASL.Pass"));
Jupiter::IRC::Client::data_->saslAccount = Jupiter::IRC::Client::readConfigValue(STRING_LITERAL_AS_REFERENCE("SASL.Account"));
if (Jupiter::IRC::Client::data_->saslAccount.size() == 0) Jupiter::IRC::Client::data_->saslAccount = Jupiter::IRC::Client::data_->nickname;
if (Jupiter::IRC::Client::data_->saslAccount.isEmpty())
Jupiter::IRC::Client::data_->saslAccount = Jupiter::IRC::Client::data_->nickname;
Jupiter::IRC::Client::data_->autoPartMessage = Jupiter::IRC::Client::readConfigValue(STRING_LITERAL_AS_REFERENCE("AutoPartMessage"));
Jupiter::IRC::Client::data_->ssl = Jupiter::IRC::Client::readConfigBool(STRING_LITERAL_AS_REFERENCE("SSL"));
Jupiter::IRC::Client::data_->SSLCertificate = Jupiter::IRC::Client::readConfigValue(STRING_LITERAL_AS_REFERENCE("Certificate"));
Jupiter::IRC::Client::data_->SSLKey = Jupiter::IRC::Client::readConfigValue(STRING_LITERAL_AS_REFERENCE("Key"));
if (Jupiter::IRC::Client::data_->SSLCertificate.size() == 0)
if (Jupiter::IRC::Client::data_->SSLCertificate.isEmpty())
{
Jupiter::IRC::Client::data_->SSLCertificate = Jupiter::IRC::Client::readConfigValue(STRING_LITERAL_AS_REFERENCE("Cert"));
if (Jupiter::IRC::Client::data_->SSLCertificate.size() == 0) Jupiter::IRC::Client::data_->SSLCertificate = Jupiter::IRC::Client::data_->SSLKey;
if (Jupiter::IRC::Client::data_->SSLCertificate.isEmpty())
Jupiter::IRC::Client::data_->SSLCertificate = Jupiter::IRC::Client::data_->SSLKey;
}
if (Jupiter::IRC::Client::data_->SSLKey.size() == 0) Jupiter::IRC::Client::data_->SSLKey = Jupiter::IRC::Client::data_->SSLCertificate;
if (Jupiter::IRC::Client::data_->SSLKey.isEmpty())
Jupiter::IRC::Client::data_->SSLKey = Jupiter::IRC::Client::data_->SSLCertificate;
Jupiter::IRC::Client::data_->joinOnKick = Jupiter::IRC::Client::readConfigBool(STRING_LITERAL_AS_REFERENCE("AutoJoinOnKick"));
Jupiter::IRC::Client::data_->reconnectDelay = Jupiter::IRC::Client::readConfigInt(STRING_LITERAL_AS_REFERENCE("AutoReconnectDelay"));
@ -161,17 +165,15 @@ Jupiter::IRC::Client::Client(const Jupiter::ReadableString &configSection)
if (Jupiter::IRC::Client::readConfigBool(STRING_LITERAL_AS_REFERENCE("PrintOutput"), true)) Jupiter::IRC::Client::data_->printOutput = stdout;
else Jupiter::IRC::Client::data_->printOutput = nullptr;
if (Jupiter::IRC::Client::data_->logFileName.size() != 0)
if (Jupiter::IRC::Client::data_->logFileName.isNotEmpty())
Jupiter::IRC::Client::data_->logFile = fopen(Jupiter::IRC::Client::data_->logFileName.c_str(), "a+b");
else Jupiter::IRC::Client::data_->logFile = nullptr;
if (Jupiter::IRC::Client::data_->ssl)
{
Jupiter::SecureTCPSocket *t = new Jupiter::SecureTCPSocket();
if (Jupiter::IRC::Client::data_->SSLCertificate.size() != 0)
{
if (Jupiter::IRC::Client::data_->SSLCertificate.isNotEmpty())
t->setCertificate(Jupiter::IRC::Client::data_->SSLCertificate, Jupiter::IRC::Client::data_->SSLKey);
}
Jupiter::IRC::Client::data_->sock = t;
}
else Jupiter::IRC::Client::data_->sock = new Jupiter::TCPSocket();
@ -542,7 +544,7 @@ int Jupiter::IRC::Client::primaryHandler()
for (unsigned int currentLine = 0; currentLine < totalLines; currentLine++)
{
Jupiter::ReferenceString buff = Jupiter::IRC::Client::data_->buffer.getWord(currentLine, ENDL);
if (buff.size() != 0)
if (buff.isNotEmpty())
{
Jupiter::IRC::Client::writeToLogs(buff);
if (Jupiter::IRC::Client::data_->printOutput != nullptr)
@ -550,13 +552,13 @@ int Jupiter::IRC::Client::primaryHandler()
buff.println(Jupiter::IRC::Client::data_->printOutput);
}
Jupiter::ReferenceString w1 = Jupiter::ReferenceString::getWord(buff, 0, WHITESPACE);
if (w1.size() != 0)
if (w1.isNotEmpty())
{
Jupiter::ReferenceString w2 = Jupiter::ReferenceString::getWord(buff, 1, WHITESPACE);
int numeric = w2.asInt(10);
if (w1[0] == ':') //Messages
{
if (w2.size() != 0)
if (w2.isNotEmpty())
{
switch (numeric) // Numerics that don't rely on a specific connectionStatus.
{
@ -653,10 +655,8 @@ int Jupiter::IRC::Client::primaryHandler()
Jupiter::IRC::Client::data_->sock = t;
Jupiter::IRC::Client::data_->ssl = true;
// toggle blocking to prevent error
if (Jupiter::IRC::Client::data_->SSLCertificate.size() != 0)
{
if (Jupiter::IRC::Client::data_->SSLCertificate.isNotEmpty())
t->setCertificate(Jupiter::IRC::Client::data_->SSLCertificate, Jupiter::IRC::Client::data_->SSLKey);
}
bool goodSSL;
if (t->getBlockingMode() == false)
@ -705,7 +705,7 @@ int Jupiter::IRC::Client::primaryHandler()
else if (curr.equalsi("userhost-in-names")) req += "userhost-in-names ";
else if (curr.equalsi("sasl"))
{
if (Jupiter::IRC::Client::data_->saslPass.size() != 0)
if (Jupiter::IRC::Client::data_->saslPass.isNotEmpty())
{
req += "sasl ";
sasl = true;
@ -776,7 +776,7 @@ int Jupiter::IRC::Client::primaryHandler()
else if (Jupiter::IRC::Client::data_->nickname.equalsi(configNick))
{
Jupiter::IRC::Client::data_->nickname = altNick;
if (Jupiter::IRC::Client::data_->nickname.size() != 0)
if (Jupiter::IRC::Client::data_->nickname.isNotEmpty())
Jupiter::IRC::Client::data_->sock->send(Jupiter::StringS::Format("NICK %.*s" ENDL, Jupiter::IRC::Client::data_->nickname.size(), Jupiter::IRC::Client::data_->nickname.ptr()));
}
// Note: Add a series of contains() functions to String_Type.
@ -895,10 +895,10 @@ int Jupiter::IRC::Client::primaryHandler()
if (w2.equalsi("PRIVMSG"))
{
Jupiter::ReferenceString chan = Jupiter::ReferenceString::getWord(buff, 2, WHITESPACE);
if (chan.size() != 0)
if (chan.isNotEmpty())
{
Jupiter::ReferenceString nick = getSender(buff);
if (nick.size() != 0)
if (nick.isNotEmpty())
{
Jupiter::ReferenceString premessage = Jupiter::ReferenceString::substring(buff, buff.find(':', 1) + 1);
if (premessage[0] == '\001') //CTCP (ACTIONs are included)
@ -958,7 +958,7 @@ int Jupiter::IRC::Client::primaryHandler()
else if (w2.equalsi("NOTICE"))
{
Jupiter::ReferenceString chan = Jupiter::ReferenceString::getWord(buff, 2, WHITESPACE);
if (chan.size() != 0)
if (chan.isNotEmpty())
{
size_t pos = buff.find('!', 0);
auto message = Jupiter::ReferenceString::substring(buff, buff.find(':', 1) + 1, buff.size());
@ -972,7 +972,7 @@ int Jupiter::IRC::Client::primaryHandler()
else
{
auto sender = getSender(buff);
if (sender.size() != 0)
if (sender.isNotEmpty())
{
this->OnServerNotice(chan, sender, message);
for (size_t i = 0; i < Jupiter::plugins->size(); i++)
@ -985,7 +985,7 @@ int Jupiter::IRC::Client::primaryHandler()
{
auto nick = getSender(buff);
Jupiter::ReferenceString newnick = Jupiter::ReferenceString::substring(buff, buff.find(' ', 1) + 1);
if (newnick.size() != 0 && newnick[0] == ':') newnick.shiftRight(1);
if (newnick.isNotEmpty() && newnick[0] == ':') newnick.shiftRight(1);
if (nick.equalsi(Jupiter::IRC::Client::data_->nickname))
{
Jupiter::IRC::Client::data_->nickname = newnick;
@ -1012,7 +1012,7 @@ int Jupiter::IRC::Client::primaryHandler()
channel->data_->isAddingNames = true;
if (channel->getType() < 0)
{
if (Jupiter::IRC::Client::data_->autoPartMessage.size() != 0)
if (Jupiter::IRC::Client::data_->autoPartMessage.isNotEmpty())
Jupiter::IRC::Client::partChannel(chan, Jupiter::IRC::Client::data_->autoPartMessage);
else
Jupiter::IRC::Client::partChannel(chan);
@ -1025,10 +1025,10 @@ int Jupiter::IRC::Client::primaryHandler()
else if (w2.equalsi("PART"))
{
auto nick = getSender(buff);
if (nick.size() != 0)
if (nick.isNotEmpty())
{
Jupiter::ReferenceString chan = Jupiter::ReferenceString::getWord(buff, 2, WHITESPACE);
if (chan.size() != 0)
if (chan.isNotEmpty())
{
int i = Jupiter::IRC::Client::getChannelIndex(chan);
if (i >= 0)
@ -1054,13 +1054,13 @@ int Jupiter::IRC::Client::primaryHandler()
else if (w2.equalsi("KICK"))
{
Jupiter::ReferenceString chan = Jupiter::ReferenceString::getWord(buff, 2, WHITESPACE);
if (chan.size() != 0)
if (chan.isNotEmpty())
{
Jupiter::ReferenceString kicker = getSender(buff);
if (kicker.size() != 0)
if (kicker.isNotEmpty())
{
Jupiter::ReferenceString kicked = Jupiter::ReferenceString::getWord(buff, 3, WHITESPACE);
if (kicked.size() != 0)
if (kicked.isNotEmpty())
{
int i = Jupiter::IRC::Client::getChannelIndex(chan);
if (i >= 0)
@ -1116,18 +1116,18 @@ int Jupiter::IRC::Client::primaryHandler()
else if (w2.equalsi("MODE"))
{
Jupiter::ReferenceString chan = Jupiter::ReferenceString::getWord(buff, 2, WHITESPACE);
if (chan.size() != 0)
if (chan.isNotEmpty())
{
if (Jupiter::IRC::Client::data_->chanTypes.contains(chan[0]))
{
auto nick = getSender(buff);
if (nick.size() != 0)
if (nick.isNotEmpty())
{
Jupiter::ReferenceString modestring = Jupiter::ReferenceString::substring(buff, buff.find(' ', 2) + 1);
if (modestring.wordCount(" ") > 1)
{
Jupiter::ReferenceString modes = modestring.getWord(0, " ");
if (modes.isEmpty() == false)
if (modes.isNotEmpty())
{
modestring.shiftRight(modestring.find(' ') + 1);
Jupiter::ReferenceString tword;
@ -1141,7 +1141,7 @@ int Jupiter::IRC::Client::primaryHandler()
{
tword = modestring.getWord(g, " ");
if (tword.isEmpty() == false)
if (tword.isNotEmpty())
{
Jupiter::IRC::Client::Channel *channel;
for (unsigned int channelIndex = 0; channelIndex < Jupiter::IRC::Client::data_->channels.size(); channelIndex++)
@ -1210,7 +1210,7 @@ int Jupiter::IRC::Client::primaryHandler()
}
else if (w1.equals("NICK"))
{
if (w2.isEmpty() == false)
if (w2.isNotEmpty())
Jupiter::IRC::Client::data_->nickname = w2;
}
else if (w1.equals("ERROR"))
@ -1223,7 +1223,7 @@ int Jupiter::IRC::Client::primaryHandler()
}
else if (w1.equals("AUTHENTICATE"))
{
if (Jupiter::IRC::Client::data_->saslPass.size() != 0)
if (Jupiter::IRC::Client::data_->saslPass.isNotEmpty())
{
size_t authStringLen = Jupiter::IRC::Client::data_->nickname.size() + Jupiter::IRC::Client::data_->saslAccount.size() + Jupiter::IRC::Client::data_->saslPass.size() + 2;
char *authString = new char[authStringLen + 1];
@ -1269,7 +1269,7 @@ int Jupiter::IRC::Client::primaryHandler()
bool Jupiter::IRC::Client::connect()
{
const Jupiter::ReadableString &clientAddress = Jupiter::IRC::Client::readConfigValue(STRING_LITERAL_AS_REFERENCE("ClientAddress"));
if (Jupiter::IRC::Client::data_->sock->connect(Jupiter::IRC::Client::data_->serverHostname.c_str(), Jupiter::IRC::Client::data_->serverPort, clientAddress.size() == 0 ? nullptr : Jupiter::CStringS(clientAddress).c_str(), (unsigned short)Jupiter::IRC::Client::readConfigLong(STRING_LITERAL_AS_REFERENCE("ClientPort"))) == false)
if (Jupiter::IRC::Client::data_->sock->connect(Jupiter::IRC::Client::data_->serverHostname.c_str(), Jupiter::IRC::Client::data_->serverPort, clientAddress.isEmpty() ? nullptr : Jupiter::CStringS(clientAddress).c_str(), (unsigned short)Jupiter::IRC::Client::readConfigLong(STRING_LITERAL_AS_REFERENCE("ClientPort"))) == false)
return false;
Jupiter::IRC::Client::data_->sock->setBlocking(false);
@ -1297,7 +1297,7 @@ void Jupiter::IRC::Client::disconnect(bool stayDead)
if (Jupiter::IRC::Client::data_->ssl)
{
Jupiter::SecureTCPSocket *t = new Jupiter::SecureTCPSocket(std::move(*Jupiter::IRC::Client::data_->sock));
if (Jupiter::IRC::Client::data_->SSLCertificate.size() != 0)
if (Jupiter::IRC::Client::data_->SSLCertificate.isNotEmpty())
t->setCertificate(Jupiter::IRC::Client::data_->SSLCertificate, Jupiter::IRC::Client::data_->SSLKey);
delete Jupiter::IRC::Client::data_->sock;
@ -1350,35 +1350,40 @@ int Jupiter::IRC::Client::think()
const Jupiter::ReadableString &Jupiter::IRC::Client::readConfigValue(const Jupiter::ReadableString &key, const Jupiter::ReadableString &defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::IRC::Client::Config->get(Jupiter::IRC::Client::data_->configSectionName, key);
if (val.size() != 0) return val;
if (val.isNotEmpty())
return val;
return Jupiter::IRC::Client::Config->get(STRING_LITERAL_AS_REFERENCE("Default"), key, defaultValue);
}
bool Jupiter::IRC::Client::readConfigBool(const Jupiter::ReadableString &key, bool defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::IRC::Client::Config->get(Jupiter::IRC::Client::data_->configSectionName, key);
if (val.size() != 0) return val.asBool();
if (val.isNotEmpty())
return val.asBool();
return Jupiter::IRC::Client::Config->getBool(STRING_LITERAL_AS_REFERENCE("Default"), key, defaultValue);
}
int Jupiter::IRC::Client::readConfigInt(const Jupiter::ReadableString &key, int defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::IRC::Client::Config->get(Jupiter::IRC::Client::data_->configSectionName, key);
if (val.size() != 0) return val.asInt();
if (val.isNotEmpty())
return val.asInt();
return Jupiter::IRC::Client::Config->getInt(STRING_LITERAL_AS_REFERENCE("Default"), key, defaultValue);
}
long Jupiter::IRC::Client::readConfigLong(const Jupiter::ReadableString &key, long defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::IRC::Client::Config->get(Jupiter::IRC::Client::data_->configSectionName, key);
if (val.size() != 0) return val.asInt();
if (val.isNotEmpty())
return val.asInt();
return Jupiter::IRC::Client::Config->getInt(STRING_LITERAL_AS_REFERENCE("Default"), key, defaultValue);
}
double Jupiter::IRC::Client::readConfigDouble(const Jupiter::ReadableString &key, double defaultValue) const
{
const Jupiter::ReadableString &val = Jupiter::IRC::Client::Config->get(Jupiter::IRC::Client::data_->configSectionName, key);
if (val.size() != 0) return val.asDouble();
if (val.isNotEmpty())
return val.asDouble();
return Jupiter::IRC::Client::Config->getDouble(STRING_LITERAL_AS_REFERENCE("Default"), key, defaultValue);
}
@ -1449,7 +1454,7 @@ void Jupiter::IRC::Client::Data::addNamesToChannel(unsigned int index, Jupiter::
for (unsigned int i = 0; i != nameLen; i++)
{
t = Jupiter::ReferenceString::getWord(names, i, " ");
if (t.size() != 0)
if (t.isNotEmpty())
{
offset = t.span(Jupiter::IRC::Client::Data::prefixes);
t.shiftRight(offset);
@ -1539,7 +1544,7 @@ Jupiter::IRC::Client::Channel::Channel(const Jupiter::ReadableString &channelNam
iFace->readConfigValue(key);
Jupiter::ReferenceString value = iFace->readConfigValue(key);
if (value.size() != 0)
if (value.isNotEmpty())
{
Jupiter::IRC::Client::Channel::data_->type = value.asInt();
return;
@ -1552,14 +1557,14 @@ Jupiter::IRC::Client::Channel::Channel(const Jupiter::ReadableString &channelNam
offset = key.aformat("%u", i);
value.set(iFace->readConfigValue(key));
if (value.size() == 0) // No more channels in the list.
if (value.isEmpty()) // No more channels in the list.
break;
if (value.getWord(0, WHITESPACE).equalsi(channelName)) // This is our channel.
{
offset += key.concat(".Type");
value.set(iFace->readConfigValue(key));
if (value.size() != 0)
if (value.isNotEmpty())
Jupiter::IRC::Client::Channel::data_->type = value.asInt();
else if (iFace->getDefaultChanType() < 0)
Jupiter::IRC::Client::Channel::data_->type = 0;

7
Jupiter/Readable_String.h

@ -71,6 +71,13 @@ namespace Jupiter
*/
virtual bool isEmpty() const;
/**
* @brief Checks if the String is not empty.
*
* @return True if the String is not empty, false otherwise.
*/
virtual bool isNotEmpty() const;
/**
* @brief Checks if the string contains an element with the specified value.
*

36
Jupiter/Readable_String_Imp.h

@ -39,6 +39,11 @@ template<typename T> bool Jupiter::Readable_String<T>::isEmpty() const
return this->size() == 0;
}
template<typename T> bool Jupiter::Readable_String<T>::isNotEmpty() const
{
return this->size() != 0;
}
// contains
template<typename T> bool Jupiter::Readable_String<T>::contains(const T &value) const
@ -64,9 +69,12 @@ template<typename T> size_t Jupiter::Readable_String<T>::find(const T &value, si
template<typename T> size_t Jupiter::Readable_String<T>::find(const Jupiter::Readable_String<T> &in) const
{
if (in.size() > this->size()) return Jupiter::INVALID_INDEX;
if (in.size() == this->size()) return this->equals(in) ? 0 : Jupiter::INVALID_INDEX;
if (in.size() == 0) return 0;
if (in.size() > this->size())
return Jupiter::INVALID_INDEX;
if (in.size() == this->size())
return this->equals(in) ? 0 : Jupiter::INVALID_INDEX;
if (in.isEmpty())
return 0;
for (size_t i = 0, j; i != this->size() - in.size() + 1; i++)
{
@ -114,9 +122,12 @@ template<typename T> size_t Jupiter::Readable_String<T>::findi(const T &value, s
template<> size_t inline Jupiter::Readable_String<char>::findi(const Jupiter::Readable_String<char> &in) const
{
if (in.size() > this->size()) return Jupiter::INVALID_INDEX;
if (in.size() == this->size()) return this->equalsi(in) ? 0 : Jupiter::INVALID_INDEX;
if (in.size() == 0) return 0;
if (in.size() > this->size())
return Jupiter::INVALID_INDEX;
if (in.size() == this->size())
return this->equalsi(in) ? 0 : Jupiter::INVALID_INDEX;
if (in.isEmpty())
return 0;
for (size_t i = 0, j; i != this->size() - in.size() + 1; i++)
{
@ -129,9 +140,12 @@ template<> size_t inline Jupiter::Readable_String<char>::findi(const Jupiter::Re
template<> size_t inline Jupiter::Readable_String<wchar_t>::findi(const Jupiter::Readable_String<wchar_t> &in) const
{
if (in.size() > this->size()) return Jupiter::INVALID_INDEX;
if (in.size() == this->size()) return this->equalsi(in) ? 0 : Jupiter::INVALID_INDEX;
if (in.size() == 0) return 0;
if (in.size() > this->size())
return Jupiter::INVALID_INDEX;
if (in.size() == this->size())
return this->equalsi(in) ? 0 : Jupiter::INVALID_INDEX;
if (in.isEmpty())
return 0;
for (size_t i = 0, j; i != this->size() - in.size() + 1; i++)
{
@ -1140,7 +1154,7 @@ template<typename T> template<template<typename> class R> R<T> Jupiter::Readable
template<typename T> template<template<typename> class R> R<T> Jupiter::Readable_String<T>::getToken(const Jupiter::Readable_String<T> &in, size_t pos, const Jupiter::Readable_String<T> &token)
{
if (token.size() == 0)
if (token.isEmpty())
return R<T>(in);
if (token.size() == 1)
return Jupiter::Readable_String<T>::getToken<R>(in, pos, token.get(0));
@ -1243,7 +1257,7 @@ template<typename T> template<template<typename> class R> R<T> Jupiter::Readable
template<typename T> template<template<typename> class R> R<T> Jupiter::Readable_String<T>::gotoToken(const Jupiter::Readable_String<T> &in, size_t pos, const Jupiter::Readable_String<T> &token)
{
if (pos == 0 || token.size() == 0)
if (pos == 0 || token.isEmpty())
return R<T>(in);
if (token.size() == 1)
return Jupiter::Readable_String<T>::gotoToken<R>(in, pos, token.get(0));

3
Jupiter/SecureSocket.cpp

@ -202,7 +202,8 @@ bool Jupiter::SecureSocket::initSSL()
ERR_print_errors_fp(stderr);
return false;
}
if (Jupiter::SecureSocket::SSLdata_->cert.size() != 0) loadCertificate(Jupiter::SecureSocket::SSLdata_->context, Jupiter::SecureSocket::SSLdata_->cert.c_str(), Jupiter::SecureSocket::SSLdata_->key.c_str());
if (Jupiter::SecureSocket::SSLdata_->cert.isNotEmpty())
loadCertificate(Jupiter::SecureSocket::SSLdata_->context, Jupiter::SecureSocket::SSLdata_->cert.c_str(), Jupiter::SecureSocket::SSLdata_->key.c_str());
Jupiter::SecureSocket::SSLdata_->handle = SSL_new(Jupiter::SecureSocket::SSLdata_->context);
if (Jupiter::SecureSocket::SSLdata_->handle == nullptr)
{

2
Jupiter/String_Type_Imp.h

@ -429,7 +429,7 @@ template<typename T> size_t Jupiter::String_Type<T>::insert(size_t index, const
if (index >= Jupiter::String_Type<T>::length)
return this->concat(value);
if (value.size() == 0)
if (value.isEmpty())
return Jupiter::String_Type<T>::length;
if (value.size() == 1)

BIN
Release/Jupiter.lib

Binary file not shown.
Loading…
Cancel
Save