void XalanOutputStream::setOutputEncoding(const XalanDOMString& theEncoding) { // Flush, just in case. This should probably be an error... flushBuffer(); XalanTranscodingServices::destroyTranscoder(m_transcoder); XalanTranscodingServices::eCode theCode = XalanTranscodingServices::OK; // This turns on an optimization that we can only do if // XalanDOMChar == sizeof(ushort). See doWrite(). #if !defined(XALAN_XALANDOMCHAR_USHORT_MISMATCH) if (XalanTranscodingServices::encodingIsUTF16(theEncoding) == true) { m_writeAsUTF16 = true; } else #endif { m_transcoder = XalanTranscodingServices::makeNewTranscoder( getMemoryManager(), theEncoding, theCode, m_transcoderBlockSize); if (theCode == XalanTranscodingServices::UnsupportedEncoding) { XalanDOMString theBuffer(getMemoryManager()); throw UnsupportedEncodingException(theEncoding, theBuffer); } else if (theCode != XalanTranscodingServices::OK) { XalanDOMString theBuffer(getMemoryManager()); throw TranscoderInternalFailureException(theEncoding, theBuffer); } assert(m_transcoder != 0); } m_encoding = theEncoding; const XalanTranscodingServices::XalanXMLByte* theProlog = XalanTranscodingServices::getStreamProlog(theEncoding); assert(theProlog != 0); const size_type theLength = XalanTranscodingServices::length(theProlog); if (theLength > 0) { #if defined(XALAN_OLD_STYLE_CASTS) write((const char*)theProlog, theLength); #else write(reinterpret_cast<const char*>(theProlog), theLength); #endif } }
//response parse bool SIM808ModemCore::genericParse_rsp(bool& rsp, char* str1, char* str2){ if ((str1 == 0) && (str2 == 0)) str1 = __ok__; rsp = theBuffer().locate(str1); if ((!rsp) && (str2 != 0)) rsp = theBuffer().locate(str2); return true; }
//Response parse. bool GSM3ShieldV1ModemCore::genericParse_rsp(bool& rsp, char* string, char* string2) { if((string==0) && (string2==0)) string=__ok__; rsp=theBuffer().locate(string); if((!rsp)&&(string2!=0)) rsp=theBuffer().locate(string2); return true; }
void GSM3ShieldV1ModemCore::manageReceivedData() { if(_debug) { /* Serial.print(theBuffer().getHead()); Serial.print(" "); Serial.println(theBuffer().getTail());*/ if(_dataInBufferFrom != _dataInBufferTo) { theBuffer().debugBuffer(); manageMsgNow(_dataInBufferFrom, _dataInBufferTo); _dataInBufferFrom=0; _dataInBufferTo=0; } } else { // Just debugging the non debugging // Serial.println(); // Serial.print("Com:"); // Serial.print(ongoingCommand); // Serial.print(" Step:"); // Serial.print(commandCounter); } }
const XMLCh* NamedNodeMapAttributeList::getValue(const char* const name) const { XalanDOMString theBuffer(m_memoryManager); return getValue(c_wstr(TranscodeFromLocalCodePage(name, theBuffer))); }
//Generic command (const string). void GSM3ShieldV1ModemCore::genericCommand_rqc(const char* str, bool addCR) { theBuffer().flush(); print(str); if(addCR) print("\r"); }
void SIM808ModemCore::genericCommand_rqc(const char* str, bool addCR){ theBuffer().Flush(); print(str); if (addCR){ print("\r\n"); } }
void GSM3ShieldV1ModemCore::manageReceivedData() { bool fullbuffer; bool firstByte=true; byte thisHead; uint8_t d = 0; if(_debug) { /* Serial.print(theBuffer().getHead()); Serial.print(" "); Serial.println(theBuffer().getTail());*/ if(_dataInBufferFrom != _dataInBufferTo) { theBuffer().debugBuffer(); manageMsgNow(_dataInBufferFrom, _dataInBufferTo); _dataInBufferFrom=0; _dataInBufferTo=0; } } else if(hwcomIsUsed == true) { // simulate the functions in original soft-Serial ISR, but get one byte one time. if(HWSerial[hwcomport]->available() > 0) { fullbuffer = (gss.cb.availableBytes()<6); if(!fullbuffer) { d = HWSerial[hwcomport]->read(); if(gss.keepThisChar(&d)) { gss.cb.write(d); if(firstByte) { firstByte=false; thisHead=gss.cb.getTail(); } } if(d==10) manageMsg(thisHead, gss.cb.getTail()); else if (d==32) manageMsg(thisHead, gss.cb.getTail()); } else manageMsg(thisHead, gss.cb.getTail()); } } else { // Just debugging the non debugging // Serial.println(); // Serial.print("Com:"); // Serial.print(ongoingCommand); // Serial.print(" Step:"); // Serial.print(commandCounter); } }
UninflatedMessage* SmallMessageHelper::deflate() const { std::vector<byte> theBuffer(kSmallMessageBufferSize); AOStreamBE theStream(&(theBuffer[0]), theBuffer.size()); reallyDeflateTo(theStream); UninflatedMessage* theDeflatedMessage = new UninflatedMessage(type(), theStream.tellp()); memcpy(theDeflatedMessage->buffer(), &(theBuffer[0]), theDeflatedMessage->length()); return theDeflatedMessage; }
void VariablesStack::pushVariable( const XalanQName& name, const XObjectPtr& val, const ElemTemplateElement* e) { if(elementFrameAlreadyPushed(e) == false) { XalanDOMString theBuffer(m_stack.getMemoryManager()); throw InvalidStackContextException(theBuffer); } push(StackEntry(&name, val)); }
void SIM808ModemCore::genericCommand_rq(PROGMEM prog_char str[], bool addCR){ digitalWrite(13,HIGH); theBuffer().Flush(); writePGM(str,addCR); digitalWrite(13, LOW); }
//Generic command (const string). void GSM3ShieldV1ModemCore::genericCommand_rq(const char* str, bool addCR) { theBuffer().flush(); writePGM(str, addCR); }
//Generic command (stored in flash). void GSM3ShieldV1ModemCore::genericCommand_rq(PROGMEM prog_char str[], bool addCR) { theBuffer().flush(); writePGM(str, addCR); }
const wxChar* wxURI::ParseServer(const wxChar* uri) { wxASSERT(uri != NULL); //copy of the uri - used for figuring out //length of each component const wxChar* uricopy = uri; // host = IP-literal / IPv4address / reg-name // IP-literal = "[" ( IPv6address / IPvFuture ) "]" if (*uri == wxT('[')) { ++uri; //some compilers don't support *&ing a ++* if (ParseIPv6address(uri) && *uri == wxT(']')) { ++uri; m_hostType = wxURI_IPV6ADDRESS; wxStringBufferLength theBuffer(m_server, uri - uricopy); wxTmemcpy(theBuffer, uricopy, uri-uricopy); theBuffer.SetLength(uri-uricopy); } else { uri = uricopy; ++uri; //some compilers don't support *&ing a ++* if (ParseIPvFuture(uri) && *uri == wxT(']')) { ++uri; m_hostType = wxURI_IPVFUTURE; wxStringBufferLength theBuffer(m_server, uri - uricopy); wxTmemcpy(theBuffer, uricopy, uri-uricopy); theBuffer.SetLength(uri-uricopy); } else uri = uricopy; } } else { if (ParseIPv4address(uri)) { m_hostType = wxURI_IPV4ADDRESS; wxStringBufferLength theBuffer(m_server, uri - uricopy); wxTmemcpy(theBuffer, uricopy, uri-uricopy); theBuffer.SetLength(uri-uricopy); } else uri = uricopy; } if(m_hostType == wxURI_REGNAME) { uri = uricopy; // reg-name = *( unreserved / pct-encoded / sub-delims ) while(*uri && *uri != wxT('/') && *uri != wxT(':') && *uri != wxT('#') && *uri != wxT('?')) { if(IsUnreserved(*uri) || IsSubDelim(*uri)) m_server += *uri++; else if (IsEscape(uri)) { m_server += *uri++; m_server += *uri++; m_server += *uri++; } else Escape(m_server, *uri++); } } //mark the server as valid m_fields |= wxURI_SERVER; return uri; }
const wxChar* wxURI::ParsePath(const wxChar* uri, bool bReference, bool bNormalize) { wxASSERT(uri != NULL); //copy of the uri - used for figuring out //length of each component const wxChar* uricopy = uri; /// hier-part = "//" authority path-abempty /// / path-absolute /// / path-rootless /// / path-empty /// /// relative-part = "//" authority path-abempty /// / path-absolute /// / path-noscheme /// / path-empty /// /// path-abempty = *( "/" segment ) /// path-absolute = "/" [ segment-nz *( "/" segment ) ] /// path-noscheme = segment-nz-nc *( "/" segment ) /// path-rootless = segment-nz *( "/" segment ) /// path-empty = 0<pchar> /// /// segment = *pchar /// segment-nz = 1*pchar /// segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" ) /// ; non-zero-length segment without any colon ":" /// /// pchar = unreserved / pct-encoded / sub-delims / ":" / "@" if (*uri == wxT('/')) { m_path += *uri++; while(*uri && *uri != wxT('#') && *uri != wxT('?')) { if( IsUnreserved(*uri) || IsSubDelim(*uri) || *uri == wxT(':') || *uri == wxT('@') || *uri == wxT('/')) m_path += *uri++; else if (IsEscape(uri)) { m_path += *uri++; m_path += *uri++; m_path += *uri++; } else Escape(m_path, *uri++); } if (bNormalize) { wxStringBufferLength theBuffer(m_path, m_path.length() + 1); #if wxUSE_STL wxTmemcpy(theBuffer, m_path.c_str(), m_path.length()+1); #endif Normalize(theBuffer, true); theBuffer.SetLength(wxStrlen(theBuffer)); } //mark the path as valid m_fields |= wxURI_PATH; } else if(*uri) //Relative path { if (bReference) { //no colon allowed while(*uri && *uri != wxT('#') && *uri != wxT('?')) { if(IsUnreserved(*uri) || IsSubDelim(*uri) || *uri == wxT('@') || *uri == wxT('/')) m_path += *uri++; else if (IsEscape(uri)) { m_path += *uri++; m_path += *uri++; m_path += *uri++; } else Escape(m_path, *uri++); } } else { while(*uri && *uri != wxT('#') && *uri != wxT('?')) { if(IsUnreserved(*uri) || IsSubDelim(*uri) || *uri == wxT(':') || *uri == wxT('@') || *uri == wxT('/')) m_path += *uri++; else if (IsEscape(uri)) { m_path += *uri++; m_path += *uri++; m_path += *uri++; } else Escape(m_path, *uri++); } } if (uri != uricopy) { if (bNormalize) { wxStringBufferLength theBuffer(m_path, m_path.length() + 1); #if wxUSE_STL wxTmemcpy(theBuffer, m_path.c_str(), m_path.length()+1); #endif Normalize(theBuffer); theBuffer.SetLength(wxStrlen(theBuffer)); } //mark the path as valid m_fields |= wxURI_PATH; } } return uri; }
void XalanOutputStream::transcode( const XalanDOMChar* theBuffer, size_type theBufferLength, TranscodeVectorType& theDestination) { if (m_transcoder == 0) { if (TranscodeToLocalCodePage( theBuffer, theBufferLength, theDestination) == false) { if (m_throwTranscodeException == true) { XalanDOMString theBuffer(theDestination.getMemoryManager()); throw TranscodingException(theBuffer); } else { } } } else { bool fDone = false; // Keep track of the total bytes we've added to the // destination vector, and the total bytes we've // eaten from theBuffer. size_type theTotalBytesFilled = 0; size_type theTotalBytesEaten = 0; // Keep track of the current position in the input buffer, // and amount remaining in the buffer, since we may not be // able to transcode it all at once. const XalanDOMChar* theBufferPosition = theBuffer; size_type theRemainingBufferLength = theBufferLength; // Keep track of the destination size, and the target size, which is // the size of the destination that has not yet been filled with // transcoded characters. Double the buffer size, in case we're // transcoding to a 16-bit encoding. // $$$ ToDo: We need to know the size of an encoding, so we can // do the right thing with the destination size. size_type theDestinationSize = theBufferLength * 2; size_type theTargetSize = theDestinationSize; do { // Resize the buffer... theDestination.resize(theDestinationSize + 1); size_type theSourceBytesEaten = 0; size_type theTargetBytesEaten = 0; XalanTranscodingServices::eCode theResult = m_transcoder->transcode( theBufferPosition, theRemainingBufferLength, #if defined(XALAN_OLD_STYLE_CASTS) (XMLByte*)&theDestination[0] + theTotalBytesFilled, #else reinterpret_cast<XMLByte*>(&theDestination[0]) + theTotalBytesFilled, #endif theTargetSize, theSourceBytesEaten, theTargetBytesEaten); if(theResult != XalanTranscodingServices::OK) { if (m_throwTranscodeException == true) { XalanDOMString theBuffer(theDestination.getMemoryManager()); throw TranscodingException(theBuffer); } } theTotalBytesFilled += theTargetBytesEaten; theTotalBytesEaten += theSourceBytesEaten; if (theTotalBytesEaten == theBufferLength) { fDone = true; } else { assert(theTotalBytesEaten < theBufferLength); // Update everything... theBufferPosition += theSourceBytesEaten; theRemainingBufferLength -= theSourceBytesEaten; // The new target size will always be the // current destination size, since we // grow by a factor of 2. This will // need to change if the factor is // every changed. theTargetSize = theDestinationSize; // Grow the destination by a factor of // two 2. See the previous comment if // you want to change this. theDestinationSize = theDestinationSize * 2; } } while(fDone == false); // Resize things, if there are any extra bytes... if (theDestination.size() != theTotalBytesFilled) { theDestination.resize(theTotalBytesFilled); } } }
bool SIM808ModemCore::genericParse_rsp(bool& rsp, char* str1, uint8_t slen){ if (slen) rsp = theBuffer().locate(str1,slen); return true; }