Skip to content
Browse files

Merge with vbouchaud/master

  • Loading branch information...
2 parents d3b7ef3 + d50d4ac commit 829c04dcd27d15a0e7f3d3c97e8ea5a5335598c9 @gierschv gierschv committed
Showing with 26 additions and 29 deletions.
  1. +26 −29 gsmlib/gsm_sms_codec.cc
View
55 gsmlib/gsm_sms_codec.cc
@@ -20,9 +20,6 @@
#include <time.h>
#include <strstream>
#include <iomanip>
-#ifdef HAVE_STRING_H
- #include <string.h>
-#endif
#include <climits>
#include <string>
@@ -30,7 +27,7 @@ using namespace gsmlib;
// Address members
-Address::Address(string number) : _plan(ISDN_Telephone)
+Address::Address(std::string number) : _plan(ISDN_Telephone)
{
number = removeWhiteSpace(number);
if (number.length() > 0 && number[0] == '+')
@@ -45,7 +42,7 @@ Address::Address(string number) : _plan(ISDN_Telephone)
}
}
-string Address::toString() const
+std::string Address::toString() const
{
if (_type == International)
return "+" + _number;
@@ -58,9 +55,9 @@ bool gsmlib::operator<(const Address &x, const Address &y)
// normalize numbers according to the following two rules:
// - prepend "+" if international number
// - append 0s to the shorter number so that both numbers have equal length
- string xnumber = x._number;
- string ynumber = y._number;
- static string twenty0s = "00000000000000000000";
+ std::string xnumber = x._number;
+ std::string ynumber = y._number;
+ static std::string twenty0s = "00000000000000000000";
if (x._type == Address::International) xnumber = "+" + xnumber;
if (y._type == Address::International) ynumber = "+" + ynumber;
@@ -93,7 +90,7 @@ bool Timestamp::empty() const
_minute == 0 && _seconds == 0 && _timeZoneMinutes == 0;
}
-string Timestamp::toString(bool appendTimeZone) const
+std::string Timestamp::toString(bool appendTimeZone) const
{
short timeZoneMinutes = _timeZoneMinutes;
short timeZoneHours = timeZoneMinutes / 60;
@@ -124,12 +121,12 @@ string Timestamp::toString(bool appendTimeZone) const
if (! appendTimeZone)
return formattedTime;
- ostrstream os;
+ std::ostrstream os;
os << formattedTime << " (" << (_negativeTimeZone ? '-' : '+')
<< setfill('0') << setw(2) << timeZoneHours
<< setw(2) << timeZoneMinutes << ')' << ends;
char *ss = os.str();
- string result(ss);
+ std::string result(ss);
delete[] ss;
return result;
}
@@ -176,7 +173,7 @@ bool gsmlib::operator==(const Timestamp &x, const Timestamp &y)
// TimePeriod members
-string TimePeriod::toString() const
+std::string TimePeriod::toString() const
{
switch (_format)
{
@@ -184,7 +181,7 @@ string TimePeriod::toString() const
return _("not present");
case Relative:
{
- ostrstream os;
+ std::ostrstream os;
if (_relativeTime <= 143)
os << ((int)_relativeTime + 1) * 5 << _(" minutes");
else if (_relativeTime <= 167)
@@ -195,7 +192,7 @@ string TimePeriod::toString() const
os << (int)_relativeTime - 192 << _(" weeks");
os << ends;
char *ss = os.str();
- string result(ss);
+ std::string result(ss);
delete[] ss;
return result;
}
@@ -208,9 +205,9 @@ string TimePeriod::toString() const
// DataCodingScheme members
-string DataCodingScheme::toString() const
+std::string DataCodingScheme::toString() const
{
- string result;
+ std::string result;
if (compressed()) result += _("compressed ");
if (messageWaitingIndication())
switch (getMessageWaitingType())
@@ -249,7 +246,7 @@ string DataCodingScheme::toString() const
// SMSDecoder members
-SMSDecoder::SMSDecoder(string pdu) : _bi(0), _septetStart(NULL)
+SMSDecoder::SMSDecoder(std::string pdu) : _bi(0), _septetStart(NULL)
{
_p = new unsigned char[pdu.length() / 2];
_op = _p;
@@ -298,9 +295,9 @@ void SMSDecoder::getOctets(unsigned char* octets, unsigned short length)
}
}
- string SMSDecoder::getSemiOctets(unsigned short length)
+ std::string SMSDecoder::getSemiOctets(unsigned short length)
{
- string result;
+ std::string result;
result.reserve(length);
alignOctet();
for (unsigned short i = 0; i < length; ++i)
@@ -399,9 +396,9 @@ unsigned long SMSDecoder::getInteger(unsigned short length)
return result;
}
-string SMSDecoder::getString(unsigned short length)
+std::string SMSDecoder::getString(unsigned short length)
{
- string result;
+ std::string result;
alignSeptet();
for (unsigned short i = 0; i < length; ++i)
{
@@ -522,7 +519,7 @@ void SMSEncoder::setOctets(const unsigned char* octets, unsigned short length)
*_op++ = octets[i];
}
-void SMSEncoder::setSemiOctets(string semiOctets)
+void SMSEncoder::setSemiOctets(std::string semiOctets)
{
alignOctet();
for (unsigned int i = 0; i < semiOctets.length(); ++i)
@@ -546,10 +543,10 @@ void SMSEncoder::setSemiOctets(string semiOctets)
void SMSEncoder::setSemiOctetsInteger(unsigned long intValue,
unsigned short length)
{
- ostrstream os;
+ std::ostrstream os;
os << intValue << ends;
char *ss = os.str();
- string s(ss);
+ std::string s(ss);
delete[] ss;
assert(s.length() <= length);
while (s.length() < length) s = '0' + s;
@@ -569,7 +566,7 @@ void SMSEncoder::setInteger(unsigned long intvalue, unsigned short length)
setBit((intvalue & (1 << i)) != 0);
}
-void SMSEncoder::setString(string stringValue)
+void SMSEncoder::setString(std::string stringValue)
{
alignSeptet();
for (unsigned int i = 0; i < stringValue.length(); ++i)
@@ -648,12 +645,12 @@ void SMSEncoder::setTimePeriod(TimePeriod period)
}
}
- string SMSEncoder::getHexString()
+ std::string SMSEncoder::getHexString()
{
short bi = _bi;
unsigned char *op = _op;
alignOctet();
- string result = bufToHex(_p, _op - _p);
+ std::string result = bufToHex(_p, _op - _p);
_bi = bi;
_op = op;
return result;
@@ -684,11 +681,11 @@ void UserDataHeader::decode(SMSDecoder &d)
unsigned char *s =
(unsigned char*)alloca(sizeof(unsigned char) * udhLen);
d.getOctets(s, udhLen);
- string ss((char*)s, (unsigned int)udhLen);
+ std::string ss((char*)s, (unsigned int)udhLen);
_udh = ss;
}
-string UserDataHeader::getIE(unsigned char id)
+std::string UserDataHeader::getIE(unsigned char id)
{
int udhl, pos = 0;

0 comments on commit 829c04d

Please sign in to comment.
Something went wrong with that request. Please try again.