本文整理汇总了C++中PString::Left方法的典型用法代码示例。如果您正苦于以下问题:C++ PString::Left方法的具体用法?C++ PString::Left怎么用?C++ PString::Left使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PString
的用法示例。
在下文中一共展示了PString::Left方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnReceivedMESSAGE
bool
Opal::Sip::EndPoint::OnReceivedMESSAGE (OpalTransport & transport,
SIP_PDU & pdu)
{
if (pdu.GetMIME().GetContentType(false) != "text/plain")
return false; // Ignore what we do not handle.
PString from = pdu.GetMIME().GetFrom();
PINDEX j = from.Find (';');
if (j != P_MAX_INDEX)
from = from.Left(j); // Remove all parameters
j = from.Find ('<');
if (j != P_MAX_INDEX && from.Find ('>') == P_MAX_INDEX)
from += '>';
SIPURL uri = from;
uri.Sanitise (SIPURL::RequestURI);
std::string display_name = (const char *) uri.GetDisplayName ();
std::string message_uri = (const char *) uri.AsString ();
std::string _message = (const char *) pdu.GetEntityBody ();
Ekiga::Message::payload_type payload;
// FIXME: we push as 'text/plain' without really knowing
payload.insert (std::make_pair ("text/plain", _message));
GTimeVal current;
g_get_current_time (¤t);
gchar* time = g_time_val_to_iso8601 (¤t);
Ekiga::Message msg = {time, display_name, payload };
g_free (time);
Ekiga::Runtime::run_in_main (boost::bind (&Opal::Sip::EndPoint::push_message_in_main, this, message_uri, msg));
return SIPEndPoint::OnReceivedMESSAGE (transport, pdu);
}
示例2: OnReceivedMESSAGE
bool
Opal::Sip::EndPoint::OnReceivedMESSAGE (OpalTransport & transport,
SIP_PDU & pdu)
{
if (pdu.GetMIME().GetContentType(false) != "text/plain")
return false; // Ignore what we do not handle.
PString from = pdu.GetMIME().GetFrom();
PINDEX j = from.Find (';');
if (j != P_MAX_INDEX)
from = from.Left(j); // Remove all parameters
j = from.Find ('<');
if (j != P_MAX_INDEX && from.Find ('>') == P_MAX_INDEX)
from += '>';
SIPURL uri = from;
uri.Sanitise (SIPURL::RequestURI);
std::string display_name = (const char *) uri.GetDisplayName ();
std::string message_uri = (const char *) uri.AsString ();
std::string _message = (const char *) pdu.GetEntityBody ();
Ekiga::Runtime::run_in_main (boost::bind (&Opal::Sip::EndPoint::push_message_in_main, this, message_uri, display_name, _message));
return SIPEndPoint::OnReceivedMESSAGE (transport, pdu);
}
示例3: m
bool Opal::Sip::EndPoint::OnReceivedMESSAGE (OpalTransport & transport,
SIP_PDU & pdu)
{
PString *last = NULL;
PString *val = NULL;
PString from = pdu.GetMIME().GetFrom();
PINDEX j = from.Find (';');
if (j != P_MAX_INDEX)
from = from.Left(j); // Remove all parameters
j = from.Find ('<');
if (j != P_MAX_INDEX && from.Find ('>') == P_MAX_INDEX)
from += '>';
PWaitAndSignal m(msgDataMutex);
last = msgData.GetAt (SIPURL (from).AsString ());
if (!last || *last != pdu.GetMIME ().GetFrom ()) {
val = new PString (pdu.GetMIME ().GetFrom ());
msgData.SetAt (SIPURL (from).AsString (), val);
SIPURL uri = from;
uri.Sanitise (SIPURL::RequestURI);
std::string display_name = (const char *) uri.GetDisplayName ();
std::string message_uri = (const char *) uri.AsString ();
std::string _message = (const char *) pdu.GetEntityBody ();
runtime.run_in_main (sigc::bind (sigc::ptr_fun (push_message_in_main), dialect, message_uri, display_name, _message));
}
return SIPEndPoint::OnReceivedMESSAGE (transport, pdu);
}
示例4: AsString
PString XMH323URL::GetDisplayName()
{
PINDEX paramIndex;
PString s = AsString();
s.Replace("h323:", "");
paramIndex = s.Find(';');
if (paramIndex != P_MAX_INDEX) {
s = s.Left(paramIndex);
}
return s;
}
示例5: GetAbsBug
PString SIDStil::GetAbsBug(PString absPathToEntry, int32 tuneNo)
{
PString tempDir;
if (baseDir.IsEmpty())
return ("");
// Determine if the baseDir is in the given pathname
if (absPathToEntry.Left(baseDir.GetLength()) != baseDir)
return ("");
// Extract the file name, relative from the base dir,
// from the entry given and convert the slashes
tempDir = absPathToEntry.Mid(baseDir.GetLength());
tempDir.Replace(P_DIRSLASH_CHR, '/');
return (GetBug(tempDir, tuneNo));
}
示例6: GetModuleInformation
bool APPlayerInfo::GetModuleInformation(int32 line, PString &description, PString &value)
{
PString tempStr;
int32 index;
PLock lock(&varLock);
// Is the line number out of range?
if (line >= modInfo.CountItems())
return (false);
// Get the information
tempStr = modInfo.GetItem(line);
// Find the spliter character between the description and value
index = tempStr.Find('\t');
if (index == -1)
return (false);
// Extract the information
description = tempStr.Left(index);
value = tempStr.Mid(index + 1);
return (true);
}
示例7: SIPURL
void
Opal::Sip::EndPoint::OnRegistrationStatus (const RegistrationStatus & status)
{
std::string info;
boost::shared_ptr<Opal::Bank> bank = core.get<Opal::Bank> ("opal-account-store");
if (!bank)
return;
Opal::AccountPtr account = bank->find_account (status.m_addressofRecord);
if (!account)
return;
if (status.m_reason == SIP_PDU::Information_Trying)
return;
SIPEndPoint::OnRegistrationStatus (status);
/* Only handle registration state transitions we are interested in.
*
* For example, if we were registering, we are interested in knowing if
* the registration was successful or not. If the registration was not
* successful and OPAL cleanly unregisters the account (as a consequence),
* we are not interested in knowing the unregistration worked.
*/
if (status.m_wasRegistering != account->is_enabled ())
return;
/* Successful registration or unregistration */
if (status.m_reason == SIP_PDU::Successful_OK) {
Ekiga::Runtime::run_in_main (boost::bind (&Opal::Account::handle_registration_event, account,
status.m_wasRegistering?Account::Registered:Account::Unregistered,
std::string (),
status.m_addressofRecord));
}
/* Registration or unregistration failure */
else {
SIPURL m_addressOfRecord = SIPURL (status.m_addressofRecord);
/* Try again in UDP mode */
if (m_addressOfRecord.GetTransportProto () == "TCP") {
SIPRegister::Params params;
PString _aor;
m_addressOfRecord.SetParamVar ("transport", "udp");
if (m_addressOfRecord.GetParamVars ().Contains ("OPAL-proxy")) {
PString proxy = m_addressOfRecord.GetParamVars().Get ("OPAL-proxy");
PINDEX p = proxy.Find (";");
if (p != P_MAX_INDEX)
proxy = proxy.Left (p);
m_addressOfRecord.SetParamVar ("OPAL-proxy", proxy);
}
params.m_addressOfRecord = m_addressOfRecord;
params.m_instanceId = GetInstanceID ();
params.m_compatibility = SIPRegister::e_RFC5626;
params.m_authID = status.m_handler->GetAuthID ();
params.m_password = status.m_handler->GetPassword ();
params.m_expire = status.m_handler->GetExpire ();
params.m_minRetryTime = PMaxTimeInterval; // use default value
params.m_maxRetryTime = PMaxTimeInterval; // use default value
if (status.m_handler->ShutDown ())
activeSIPHandlers.Remove (status.m_handler); // Make sure the TCP handler is deleted
// or it will be retried indefinitely.
SIPEndPoint::Register (params, _aor);
return;
}
/* all these codes are defined in opal, file include/sip/sippdu.h */
switch (status.m_reason) {
case SIP_PDU::IllegalStatusCode:
info = _("Illegal status code");
break;
case SIP_PDU::Local_TransportError:
info = _("Transport error");
break;
case SIP_PDU::Local_BadTransportAddress:
info = _("Invalid address");
break;
case SIP_PDU::Local_Timeout:
/* Translators: Host of the remote party is offline, this should
* appear when the remote host does not reply in an acceptable time */
info = _("Remote party host is offline");
break;
case SIP_PDU::Information_Trying:
case SIP_PDU::Information_Ringing:
case SIP_PDU::Information_CallForwarded:
case SIP_PDU::Information_Queued:
case SIP_PDU::Information_Session_Progress:
case SIP_PDU::Successful_OK:
case SIP_PDU::Successful_Accepted:
break;
case SIP_PDU::Redirection_MultipleChoices:
/* Translators: the following strings are answers from the SIP server
* when the packet it receives has an error, see
* http://www.ietf.org/rfc/rfc3261.txt, chapter 21 for more information */
info = _("Multiple choices");
break;
//.........这里部分代码省略.........
示例8: PositionToEntry
bool SIDStil::PositionToEntry(PString entryStr, PFile *inFile, PList<DirList *> &dirs)
{
DirList *item = NULL;
int32 slashIndex;
int32 startPos;
int32 i, count;
int32 pathLen, entryStrLen;
PString line;
bool foundIt = false;
bool globComm = false;
bool temp;
PCharSet_MS_WIN_1252 charSet;
try
{
// Seek to the start of the file
inFile->SeekToBegin();
// Get the dirpath
slashIndex = entryStr.ReverseFind('/');
// If no slash was found, something is screwed up in the entryStr
if (slashIndex == -1)
return (false);
pathLen = slashIndex + 1;
// Determine whether a section-global comment is asked for
entryStrLen = entryStr.GetLength();
if (pathLen == entryStrLen)
globComm = true;
// Find it in the table
count = dirs.CountItems();
for (i = 0; i < count; i++)
{
item = dirs.GetItem(i);
if (entryStr.Left(pathLen) == item->dirName)
{
foundIt = true;
break;
}
}
if (!foundIt)
{
// The directory was not found
return (false);
}
// Jump to the first entry of this section
inFile->Seek(item->position, PFile::pSeekBegin);
foundIt = false;
// Now find the desired entry
do
{
startPos = inFile->GetPosition();
line = inFile->ReadLine(&charSet);
if (inFile->IsEOF())
break;
// Check if it is the start of an entry
if (!line.IsEmpty() && (line.GetAt(0) == '/'))
{
if (line.Left(pathLen) != item->dirName)
{
// We are outside the section - get out of the loop,
// which will fail the search
break;
}
// Check whether we need to find a section-global comment or
// a specific entry
if (globComm || (stilVersion > 2.59f))
temp = (line == entryStr);
else
{
// To be compatible with older versions of STIL, which may have
// the tune designation on the first line of a STIL entry
// together with the pathname
temp = (line.Left(entryStrLen) == entryStr);
}
if (temp)
{
// Found it!
foundIt = true;
}
}
}
while (!foundIt);
if (foundIt)
{
// Reposition the file pointer back to the start of the entry
inFile->Seek(startPos, PFile::pSeekBegin);
return (true);
}
//.........这里部分代码省略.........
示例9: GetGlobalComment
PString SIDStil::GetGlobalComment(PString relPathToEntry)
{
PString dir;
int32 lastSlash, pathLen;
int32 temp;
if (baseDir.IsEmpty())
return ("");
// Save the dirpath
lastSlash = relPathToEntry.ReverseFind('/');
if (lastSlash == -1)
return ("");
pathLen = lastSlash + 1;
dir = relPathToEntry.Left(pathLen);
// Find out whether we have this global comment in the buffer.
// If the baseDir was changed, we'll have to read it in again,
// even if it might be in the buffer already
if ((globalBuf.Left(dir.GetLength()) != dir) || ((globalBuf.Find('\n') != pathLen) && (stilVersion > 2.59f)))
{
// The relative pathnames don't match or they're not the same length:
// We don't have it in the buffer, so pull it in
try
{
PDirectory tempDir;
tempDir.SetDirectory(baseDir);
tempDir.Append("DOCUMENTS");
stilFile->Open(tempDir.GetDirectory() + "STIL.txt", PFile::pModeRead | PFile::pModeShareRead);
if (PositionToEntry(dir, stilFile, stilDirs) == false)
{
// Copy the dirname to the buffer
globalBuf = dir + "\n";
}
else
{
globalBuf.MakeEmpty();
ReadEntry(stilFile, globalBuf);
}
stilFile->Close();
}
catch(PFileException e)
{
// Failed reading from the STIL.txt file
stilFile->Close();
return ("");
}
}
// Position the index to the global comment field
temp = globalBuf.Find('\n');
temp++;
// Check whether this is a NULL entry or not
if (temp == globalBuf.GetLength())
return ("");
return (globalBuf.Mid(temp));
}