Browse files

correcting some string things.

  • Loading branch information...
1 parent 17e735e commit c39fff48992b449935ef63e467ea468edeae4bf1 @vbouchaud committed Sep 4, 2011
Showing with 23 additions and 26 deletions.
  1. +23 −26 gsmlib/gsm_sms_codec.cc
View
49 gsmlib/gsm_sms_codec.cc
@@ -20,17 +20,14 @@
#include <time.h>
#include <strstream>
#include <iomanip>
-#ifdef HAVE_STRING_H
- #include <string.h>
-#endif
#include <climits>
#include <string>
using namespace gsmlib;
// Address members
-Address::Address(std::string number) : _plan(ISDN_Telephone)
+Address::Address(std::std::string number) : _plan(ISDN_Telephone)
{
number = removeWhiteSpace(number);
if (number.length() > 0 && number[0] == '+')
@@ -45,7 +42,7 @@ Address::Address(std::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
- std::string xnumber = x._number;
- std::string ynumber = y._number;
- static std::string twenty0s = "00000000000000000000";
+ std::std::string xnumber = x._number;
+ std::std::string ynumber = y._number;
+ static std::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;
@@ -129,7 +126,7 @@ string Timestamp::toString(bool appendTimeZone) const
<< setfill('0') << setw(2) << timeZoneHours
<< setw(2) << timeZoneMinutes << ')' << ends;
char *ss = os.str();
- std::string result(ss);
+ std::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)
{
@@ -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
{
- std::string result;
+ std::std::string result;
if (compressed()) result += _("compressed ");
if (messageWaitingIndication())
switch (getMessageWaitingType())
@@ -249,7 +246,7 @@ string DataCodingScheme::toString() const
// SMSDecoder members
-SMSDecoder::SMSDecoder(std::string pdu) : _bi(0), _septetStart(NULL)
+SMSDecoder::SMSDecoder(std::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)
}
}
- std::string SMSDecoder::getSemiOctets(unsigned short length)
+ std::std::string SMSDecoder::getSemiOctets(unsigned short length)
{
- std::string result;
+ std::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)
{
- std::string result;
+ std::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(std::string semiOctets)
+void SMSEncoder::setSemiOctets(std::std::string semiOctets)
{
alignOctet();
for (unsigned int i = 0; i < semiOctets.length(); ++i)
@@ -549,7 +546,7 @@ void SMSEncoder::setSemiOctetsInteger(unsigned long intValue,
ostrstream os;
os << intValue << ends;
char *ss = os.str();
- std::string s(ss);
+ std::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(std::string stringValue)
+void SMSEncoder::setString(std::std::string stringValue)
{
alignSeptet();
for (unsigned int i = 0; i < stringValue.length(); ++i)
@@ -648,12 +645,12 @@ void SMSEncoder::setTimePeriod(TimePeriod period)
}
}
- std::string SMSEncoder::getHexString()
+ std::std::string SMSEncoder::getHexString()
{
short bi = _bi;
unsigned char *op = _op;
alignOctet();
- std::string result = bufToHex(_p, _op - _p);
+ std::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);
- std::string ss((char*)s, (unsigned int)udhLen);
+ std::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 c39fff4

Please sign in to comment.