cxString cxStringAllocChars(cxConstChars str) { CX_ASSERT(str != NULL, "str null"); cxString rv = CX_ALLOC(cxString); cxStringAppend(rv, (void *)str, (cxInt)strlen(str)); return rv; }
static cxString cxMp3StreamAllBytes(cxAny stream) { cxStream this = stream; if(!this->canRead){ cxStreamOpen(this); } if(!this->canRead){ CX_ERROR("file stream can't read"); return NULL; } cxInt bufsiz = 0; cxPointer buffer = cxMp3StreamBuffer(this, &bufsiz); cxString data = CX_CREATE(cxString); cxInt bytes = 0; while((bytes = cxStreamRead(this,buffer,bufsiz)) > 0){ cxStringAppend(data, buffer,bytes); } cxStreamClose(this); return data; }
cxArray cxStringSplit(cxString string,cxConstChars sp) { CX_ASSERT(string != NULL, "args error"); cxConstChars body = cxStringBody(string); cxInt length = cxStringLength(string) + 1; cxChar buffer[length]; cxInt idx = 0; cxArray ret = CX_CREATE(cxArray); for(cxInt i=0; i < length; i++){ if(!cxConstCharsHasChar(sp, body[i]) && body[i] != '\0'){ buffer[idx++] = body[i]; continue; } if(idx == 0){ continue; } cxString item = CX_CREATE(cxString); cxStringAppend(item, buffer, idx); cxArrayAppend(ret, item); idx = 0; } return ret; }
cxString cxStringBinary(cxPointer d,cxInt l) { cxString rv = CX_CREATE(cxString); cxStringAppend(rv, d, l); return rv; }