本文整理汇总了C++中output函数的典型用法代码示例。如果您正苦于以下问题:C++ output函数的具体用法?C++ output怎么用?C++ output使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了output函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: output
string CCJSONArray::toString() {
CCMemoryOutputStream mos;
output(&mos);
return string(mos.getBuffer(), mos.getLength());
}
示例2: ngx_http_image_handler
static ngx_int_t ngx_http_image_handler(ngx_http_request_t *r)
{
u_char *last;
size_t root;
ngx_int_t rc;
ngx_str_t path;
char request_uri[255];
int request_uri_len;
ngx_image_conf_t *conf;
conf = ngx_http_get_module_loc_conf(r, ngx_http_image_module);
if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD)))
{
return NGX_HTTP_NOT_ALLOWED;
}
if (r->headers_in.if_modified_since)
{
return NGX_HTTP_NOT_MODIFIED;
}
if (r->uri.data[r->uri.len - 1] == '/')
{
return NGX_DECLINED;
}
rc = ngx_http_discard_request_body(r);
if (rc != NGX_OK)
{
return rc;
}
last = ngx_http_map_uri_to_path(r, &path, &root, 0);
if (last == NULL)
{
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
if(file_exists((char*) path.data) == -1)
{
request_uri_len = strlen((char *)r->uri_start) - strlen((char *)r->uri_end);
strncpy(request_uri, (char *)r->uri_start, request_uri_len);
request_uri[request_uri_len] = '\0';
conf->request_dir = dirname(request_uri);
conf->url = request_uri;//请求的URL地址
conf->dest_file = (char *)path.data;
check_image_type(conf);//检查图片类型(根据后缀进行简单判断)
if( conf->dest_type > 0 )
{
if (parse_image_info(conf) == 0)//解析并处理请求的图片URL
{
make_thumb(conf);//生成图片缩略图
water_mark(conf);//图片打上水印
thumb_to_string(conf);//GD对象转换成二进制字符串
if(conf->image_output == 0)
{
write_img(conf);//保存图片缩略图到文件
}
if(conf->src_im != NULL){
gdImageDestroy(conf->src_im);
}
if(conf->dst_im != NULL)
{
gdImageDestroy(conf->dst_im);
}
if(conf->water_im != NULL)
{
gdImageDestroy(info->water_im);
}
if(conf->w_margin > 0 && conf->w_im != NULL)
{
gdImageDestroy(conf->w_im);//释放补白边的对象
}
if(conf->image_output == 1)
{
return output(r,conf,ngx_http_image_types[conf->dest_type]);
}
}
}
}
return NGX_DECLINED;
}
示例3: MPreFixups
le_int32 IndicReordering::reorder(const LEUnicode *chars, le_int32 charCount, le_int32 scriptCode,
LEUnicode *outChars, LEGlyphStorage &glyphStorage,
MPreFixups **outMPreFixups, LEErrorCode& success)
{
if (LE_FAILURE(success)) {
return 0;
}
MPreFixups *mpreFixups = NULL;
const IndicClassTable *classTable = IndicClassTable::getScriptClassTable(scriptCode);
if (classTable==NULL) {
success = LE_INTERNAL_ERROR;
return 0;
}
if (classTable->scriptFlags & SF_MPRE_FIXUP) {
mpreFixups = new MPreFixups(charCount);
if (mpreFixups == NULL) {
success = LE_MEMORY_ALLOCATION_ERROR;
return 0;
}
}
IndicReorderingOutput output(outChars, glyphStorage, mpreFixups);
le_int32 i, prev = 0;
le_bool lastInWord = FALSE;
while (prev < charCount) {
le_int32 syllable = findSyllable(classTable, chars, prev, charCount);
le_int32 matra, markStart = syllable;
output.reset();
if (classTable->isStressMark(chars[markStart - 1])) {
markStart -= 1;
output.noteStressMark(classTable, chars[markStart], markStart, tagArray1);
}
if (markStart != prev && classTable->isVowelModifier(chars[markStart - 1])) {
markStart -= 1;
output.noteVowelModifier(classTable, chars[markStart], markStart, tagArray1);
}
matra = markStart - 1;
while (output.noteMatra(classTable, chars[matra], matra, tagArray1, !lastInWord) && matra != prev) {
matra -= 1;
}
lastInWord = TRUE;
switch (classTable->getCharClass(chars[prev]) & CF_CLASS_MASK) {
case CC_RESERVED:
lastInWord = FALSE;
/* fall through */
case CC_INDEPENDENT_VOWEL:
case CC_ZERO_WIDTH_MARK:
for (i = prev; i < syllable; i += 1) {
output.writeChar(chars[i], i, tagArray1);
}
break;
case CC_AL_LAKUNA:
case CC_NUKTA:
output.writeChar(C_DOTTED_CIRCLE, prev, tagArray1);
output.writeChar(chars[prev], prev, tagArray1);
break;
case CC_VIRAMA:
// A lone virama is illegal unless it follows a
// MALAYALAM_VOWEL_SIGN_U. Such a usage is called
// "samvruthokaram".
if (chars[prev - 1] != C_MALAYALAM_VOWEL_SIGN_U) {
output.writeChar(C_DOTTED_CIRCLE, prev, tagArray1);
}
output.writeChar(chars[prev], prev, tagArray1);
break;
case CC_DEPENDENT_VOWEL:
case CC_SPLIT_VOWEL_PIECE_1:
case CC_SPLIT_VOWEL_PIECE_2:
case CC_SPLIT_VOWEL_PIECE_3:
case CC_VOWEL_MODIFIER:
case CC_STRESS_MARK:
output.writeMpre();
output.writeChar(C_DOTTED_CIRCLE, prev, tagArray1);
output.writeMbelow();
output.writeSMbelow();
output.writeMabove();
if ((classTable->scriptFlags & SF_MATRAS_AFTER_BASE) != 0) {
output.writeMpost();
}
//.........这里部分代码省略.........
示例4: ip6_fragment
int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
{
struct sk_buff *frag;
struct rt6_info *rt = (struct rt6_info*)skb_dst(skb);
struct ipv6_pinfo *np = skb->sk ? inet6_sk(skb->sk) : NULL;
struct ipv6hdr *tmp_hdr;
struct frag_hdr *fh;
unsigned int mtu, hlen, left, len;
int hroom, troom;
__be32 frag_id = 0;
int ptr, offset = 0, err=0;
u8 *prevhdr, nexthdr = 0;
struct net *net = dev_net(skb_dst(skb)->dev);
hlen = ip6_find_1stfragopt(skb, &prevhdr);
nexthdr = *prevhdr;
mtu = ip6_skb_dst_mtu(skb);
/* We must not fragment if the socket is set to force MTU discovery
* or if the skb it not generated by a local socket.
*/
if (unlikely(!skb->local_df && skb->len > mtu) ||
(IP6CB(skb)->frag_max_size &&
IP6CB(skb)->frag_max_size > mtu)) {
if (skb->sk && dst_allfrag(skb_dst(skb)))
sk_nocaps_add(skb->sk, NETIF_F_GSO_MASK);
skb->dev = skb_dst(skb)->dev;
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)),
IPSTATS_MIB_FRAGFAILS);
kfree_skb(skb);
return -EMSGSIZE;
}
if (np && np->frag_size < mtu) {
if (np->frag_size)
mtu = np->frag_size;
}
mtu -= hlen + sizeof(struct frag_hdr);
if (skb_has_frag_list(skb)) {
int first_len = skb_pagelen(skb);
struct sk_buff *frag2;
if (first_len - hlen > mtu ||
((first_len - hlen) & 7) ||
skb_cloned(skb))
goto slow_path;
skb_walk_frags(skb, frag) {
/* Correct geometry. */
if (frag->len > mtu ||
((frag->len & 7) && frag->next) ||
skb_headroom(frag) < hlen)
goto slow_path_clean;
/* Partially cloned skb? */
if (skb_shared(frag))
goto slow_path_clean;
BUG_ON(frag->sk);
if (skb->sk) {
frag->sk = skb->sk;
frag->destructor = sock_wfree;
}
skb->truesize -= frag->truesize;
}
err = 0;
offset = 0;
frag = skb_shinfo(skb)->frag_list;
skb_frag_list_init(skb);
/* BUILD HEADER */
*prevhdr = NEXTHDR_FRAGMENT;
tmp_hdr = kmemdup(skb_network_header(skb), hlen, GFP_ATOMIC);
if (!tmp_hdr) {
IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)),
IPSTATS_MIB_FRAGFAILS);
return -ENOMEM;
}
__skb_pull(skb, hlen);
fh = (struct frag_hdr*)__skb_push(skb, sizeof(struct frag_hdr));
__skb_push(skb, hlen);
skb_reset_network_header(skb);
memcpy(skb_network_header(skb), tmp_hdr, hlen);
ipv6_select_ident(fh, rt);
fh->nexthdr = nexthdr;
fh->reserved = 0;
fh->frag_off = htons(IP6_MF);
frag_id = fh->identification;
first_len = skb_pagelen(skb);
skb->data_len = first_len - skb_headlen(skb);
skb->len = first_len;
ipv6_hdr(skb)->payload_len = htons(first_len -
//.........这里部分代码省略.........
示例6: output
//
// Maya calls this method to have the translator write out a file.
//
MStatus maTranslator::writer(
const MFileObject& file,
const MString& /* options */,
MPxFileTranslator::FileAccessMode mode
)
{
//
// For simplicity, we only do full saves/exports.
//
if ((mode != kSaveAccessMode) && (mode != kExportAccessMode))
return MS::kNotImplemented;
//
// Let's see if we can open the output file.
//
fstream output(file.fullName().asChar(), ios::out | ios::trunc);
if (!output.good()) return MS::kNotFound;
//
// Get some node flags to keep track of those nodes for which we
// have already done various stages of processing.
//
MStatus status;
fCreateFlag = MFnDependencyNode::allocateFlag(fPluginName, &status);
if (status)
fAttrFlag = MFnDependencyNode::allocateFlag(fPluginName, &status);
if (status)
fConnectionFlag = MFnDependencyNode::allocateFlag(fPluginName, &status);
if (!status)
{
MGlobal::displayError(
"Could not allocate three free node flags."
" Try unloading some other plugins."
);
return MS::kFailure;
}
//
// Run through all of the nodes in the scene and clear their flags.
//
MItDependencyNodes nodesIter;
for (; !nodesIter.isDone(); nodesIter.next())
{
MObject node = nodesIter.item();
MFnDependencyNode nodeFn(node);
nodeFn.setFlag(fCreateFlag, false);
nodeFn.setFlag(fAttrFlag, false);
nodeFn.setFlag(fConnectionFlag, false);
}
//
// Write out the various sections of the file.
//
writeHeader(output, file.name());
writeFileInfo(output);
writeReferences(output);
writeRequirements(output);
writeUnits(output);
writeDagNodes(output);
writeNonDagNodes(output);
writeDefaultNodes(output);
writeReferenceNodes(output);
writeConnections(output);
writeFooter(output, file.name());
output.close();
MFnDependencyNode::deallocateFlag(fPluginName, fCreateFlag);
return MS::kSuccess;
}
示例7: logFileError
//.........这里部分代码省略.........
{
result = -1;
}
#endif
} else {
// No config file
#ifndef _WIN32_WCE
result = system(QFile::encodeName(QString("%1 2> %2").arg(cmd, scriptErr.fileName())));
#else
QString path_ = QDir::convertSeparators ( QFileInfo ( cmd ).absoluteFilePath() );
QString file_ = QFileInfo ( cmd ).fileName();
SHELLEXECUTEINFO execInfo;
memset ( &execInfo,0,sizeof ( execInfo ) );
execInfo.cbSize = sizeof ( execInfo );
execInfo.fMask = SEE_MASK_FLAG_NO_UI;
execInfo.lpVerb = L"open";
execInfo.lpFile = (LPCWSTR) path_.utf16();
execInfo.lpDirectory = (LPCWSTR) file_.utf16();
execInfo.lpParameters = (LPCWSTR) QString(" 2> %1").arg( scriptErr.fileName()).utf16();
result = ShellExecuteEx ( &execInfo );
if (result != 0)
{
result = 0;
}
else
{
result = -1;
}
#endif
}
// Copy script stderr to log file
{
QFile output(scriptErr.fileName());
if (output.open(QIODevice::ReadOnly)) {
QTextStream ts(&output);
ts.setCodec(QTextCodec::codecForName("UTF-8"));
while (!ts.atEnd()) {
QString line = ts.readLine();
log() << "[Script] " << line << endl;
}
}
}
if (result) {
log() << m_currentFilename << ": !! An error occurred while running '" << cmd << "'" << endl;
return;
}
if (!m_oldConfig1) {
return; // Nothing to merge
}
if (m_debug) {
scriptOut.setAutoRemove(false);
log() << "Script output stored in " << scriptOut.fileName() << endl;
}
// Deleting old entries
{
QStringList group = m_oldGroup;
QFile output(scriptOut.fileName());
if (output.open(QIODevice::ReadOnly)) {
QTextStream ts(&output);
ts.setCodec(QTextCodec::codecForName("UTF-8"));
while (!ts.atEnd()) {
示例8: main
//.........这里部分代码省略.........
ungetc(c, fp_restore);
if (fgetc(fp_restore) == 'x')
{
fscanf(fp_restore, "%lf %lf\n", &lower, &upper);
while(fscanf(fp_restore,"%d %lf %lf\n",&idx,&fmin,&fmax)==3)
{
for(i = next_index;i<idx;i++)
if(feature_min[i] != feature_max[i])
fprintf(stderr,
"WARNING: feature index %d appeared in file %s was not seen in the scaling factor file %s.\n",
i, argv[argc-1], restore_filename);
feature_min[idx] = fmin;
feature_max[idx] = fmax;
next_index = idx + 1;
}
for(i=next_index;i<=max_index;i++)
if(feature_min[i] != feature_max[i])
fprintf(stderr,
"WARNING: feature index %d appeared in file %s was not seen in the scaling factor file %s.\n",
i, argv[argc-1], restore_filename);
}
fclose(fp_restore);
}
if(save_filename)
{
FILE *fp_save = fopen(save_filename,"w");
if(fp_save==NULL)
{
fprintf(stderr,"can't open file %s\n", save_filename);
exit(1);
}
if(y_scaling)
{
fprintf(fp_save, "y\n");
fprintf(fp_save, "%.16g %.16g\n", y_lower, y_upper);
fprintf(fp_save, "%.16g %.16g\n", y_min, y_max);
}
fprintf(fp_save, "x\n");
fprintf(fp_save, "%.16g %.16g\n", lower, upper);
for(i=1;i<=max_index;i++)
{
if(feature_min[i]!=feature_max[i])
fprintf(fp_save,"%d %.16g %.16g\n",i,feature_min[i],feature_max[i]);
}
if(min_index < 1)
fprintf(stderr,
"WARNING: scaling factors with indices smaller than 1 are not stored to the file %s.\n", save_filename);
fclose(fp_save);
}
while(readline(fp)!=NULL)
{
char *p=line;
int next_index=1;
double target;
double value;
sscanf(p,"%lf",&target);
output_target(target);
SKIP_TARGET
while(sscanf(p,"%d:%lf",&index,&value)==2)
{
for(i=next_index;i<index;i++)
output(i,0);
output(index,value);
SKIP_ELEMENT
next_index=index+1;
}
for(i=next_index;i<=max_index;i++)
output(i,0);
printf("\n");
}
if (new_num_nonzeros > num_nonzeros)
fprintf(stderr,
"WARNING: original #nonzeros %ld\n"
" new #nonzeros %ld\n"
"Use -l 0 if many original feature values are zeros\n",
num_nonzeros, new_num_nonzeros);
free(line);
free(feature_max);
free(feature_min);
fclose(fp);
return 0;
}
示例9: open_if_block
void
open_if_block (const char *c_cond)
{
output ("if (%s)", c_cond);
block_begin ();
}
示例10: block_end
void
block_end (void)
{
adjust_indent (-3);
output ("}");
}
示例11: block_begin
void
block_begin (void)
{
output ("{");
adjust_indent (+3);
}
示例12: start_i2c
static void start_i2c(void)
{
output(1, 1, 0); usleep(1000); // stopped (SCL = 1, SDA = 1)
output(1, 0, 0); usleep(1000); // running (SCL = 0)
}
示例13: main
int main(int argc, char * argv[])
{
pid_t child;
pthread_mutex_t mtx;
pthread_mutexattr_t ma[4];
pthread_mutexattr_t *pma[5];
int ret=0;
int i;
int retini[5] = {-1,-1,-1,-1,-1};
int retdtr[5]= {-1,-1,-1,-1,-1};
void * ptr, *ptr_prev=NULL;
int sz = 0;
struct rlimit rl;
int status=0;
output_init();
child = fork();
if (child == (pid_t)-1)
{ UNRESOLVED(errno, "Fork failed"); }
if (child != 0) /* We are the father */
{
if (child != waitpid(child, &status, 0))
{ UNRESOLVED(errno, "Waitpid failed"); }
if (WIFSIGNALED(status))
{ UNRESOLVED(WTERMSIG(status),
"The child process was killed."); }
if (WIFEXITED(status))
return WEXITSTATUS(status);
UNRESOLVED(0, "Child process neither returned nor was killed.");
}
/* Only the child goes further */
/* We initialize the different mutex attributes */
for (i=0; (i<4) && (ret == 0); i++)
{
pma[i] = &ma[i];
ret = pthread_mutexattr_init(pma[i]);
}
if (ret)
{ UNRESOLVED(ret, "Mutex attribute init failed"); }
pma[4] = (pthread_mutexattr_t *) NULL;
if ((ret = pthread_mutexattr_settype(pma[0], PTHREAD_MUTEX_NORMAL)))
{ UNRESOLVED(ret, "Mutex attribute NORMAL failed"); }
if ((ret = pthread_mutexattr_settype(pma[0], PTHREAD_MUTEX_DEFAULT)))
{ UNRESOLVED(ret, "Mutex attribute DEFAULT failed"); }
if ((ret = pthread_mutexattr_settype(pma[0], PTHREAD_MUTEX_RECURSIVE)))
{ UNRESOLVED(ret, "Mutex attribute RECURSIVE failed"); }
if ((ret = pthread_mutexattr_settype(pma[0], PTHREAD_MUTEX_ERRORCHECK)))
{ UNRESOLVED(ret, "Mutex attribute ERRORCHECK failed"); }
sz = sysconf(_SC_PAGESIZE);
/* Limit the process memory to a small value (64Mb for example). */
rl.rlim_max=1024*1024*64;
rl.rlim_cur=1024*1024*64;
if ((ret = setrlimit(RLIMIT_AS, &rl)))
{ UNRESOLVED(ret, "Memory limitation failed"); }
#if VERBOSE > 1
output("Ready to take over memory. Page size is %d\n", sz);
#endif
/* Allocate all available memory */
while (1)
{
ptr = malloc( sz ); /* Allocate one page of memory */
if (ptr == NULL)
break;
#if VERBOSE > 1
ret++;
#endif
*(void **)ptr = ptr_prev; /* Write into the allocated page */
ptr_prev = ptr;
}
#if VERBOSE > 1
output("%d pages were allocated before failure\n", ret);
ret = 0;
#endif
while (1)
{
ptr = malloc( sizeof(void*) ); /* Allocate every remaining bits of memory */
if (ptr == NULL)
break;
//.........这里部分代码省略.........
示例14: send_bit_i2c
static void send_bit_i2c(uint32_t v)
{
output(1, 0, v); usleep(100); // running (SCL = 0)
output(1, 1, v); usleep(100);
output(1, 0, v); usleep(100); // running (SCL = 0)
}
示例15: output
~MP4FileStream()
{
if(!bStreamOpened)
return;
App->EnableSceneSwitching(false);
//---------------------------------------------------
//HWND hwndProgressDialog = CreateDialog(hinstMain, MAKEINTRESOURCE(IDD_BUILDINGMP4), hwndMain, (DLGPROC)MP4ProgressDialogProc);
//SendMessage(GetDlgItem(hwndProgressDialog, IDC_PROGRESS1), PBM_SETRANGE32, 0, 100);
mdatStop = fileOut.GetPos();
BufferOutputSerializer output(endBuffer);
UINT64 audioFrameSize = App->GetAudioEncoder()->GetFrameSize();
DWORD macTime = fastHtonl(DWORD(GetMacTime()));
UINT videoDuration = fastHtonl(lastVideoTimestamp + App->GetFrameTime());
UINT audioDuration = fastHtonl(lastVideoTimestamp + DWORD(double(audioFrameSize)/44.1));
UINT width, height;
App->GetOutputSize(width, height);
LPCSTR lpVideoTrack = "Video Media Handler";
LPCSTR lpAudioTrack = "Sound Media Handler";
char videoCompressionName[31] = "AVC Coding";
//-------------------------------------------
// get video headers
DataPacket videoHeaders;
App->GetVideoHeaders(videoHeaders);
List<BYTE> SPS, PPS;
LPBYTE lpHeaderData = videoHeaders.lpPacket+11;
SPS.CopyArray(lpHeaderData+2, fastHtons(*(WORD*)lpHeaderData));
lpHeaderData += SPS.Num()+3;
PPS.CopyArray(lpHeaderData+2, fastHtons(*(WORD*)lpHeaderData));
//-------------------------------------------
// get AAC headers if using AAC
List<BYTE> AACHeader;
if(!bMP3)
{
DataPacket data;
App->GetAudioHeaders(data);
AACHeader.CopyArray(data.lpPacket+2, data.size-2);
}
//-------------------------------------------
EndChunkInfo(videoChunks, videoSampleToChunk, curVideoChunkOffset, numVideoSamples);
EndChunkInfo(audioChunks, audioSampleToChunk, curAudioChunkOffset, numAudioSamples);
if (numVideoSamples > 1)
GetVideoDecodeTime(videoFrames.Last(), true);
if (numAudioSamples > 1)
GetAudioDecodeTime(audioFrames.Last(), true);
UINT audioUnitDuration = fastHtonl(UINT(lastAudioTimeVal));
//SendMessage(GetDlgItem(hwndProgressDialog, IDC_PROGRESS1), PBM_SETPOS, 25, 0);
//-------------------------------------------
// sound descriptor thingy. this part made me die a little inside admittedly.
UINT maxBitRate = fastHtonl(App->GetAudioEncoder()->GetBitRate()*1000);
List<BYTE> esDecoderDescriptor;
BufferOutputSerializer esDecoderOut(esDecoderDescriptor);
esDecoderOut.OutputByte(bMP3 ? 107 : 64);
esDecoderOut.OutputByte(0x15); //stream/type flags. always 0x15 for my purposes.
esDecoderOut.OutputByte(0); //buffer size, just set it to 1536 for both mp3 and aac
esDecoderOut.OutputWord(WORD_BE(0x600));
esDecoderOut.OutputDword(maxBitRate); //max bit rate (cue bill 'o reily meme for these two)
esDecoderOut.OutputDword(maxBitRate); //avg bit rate
if(!bMP3) //if AAC, put in headers
{
esDecoderOut.OutputByte(0x5); //decoder specific descriptor type
/*esDecoderOut.OutputByte(0x80); //some stuff that no one should probably care about
esDecoderOut.OutputByte(0x80);
esDecoderOut.OutputByte(0x80);*/
esDecoderOut.OutputByte(AACHeader.Num());
esDecoderOut.Serialize((LPVOID)AACHeader.Array(), AACHeader.Num());
}
List<BYTE> esDescriptor;
BufferOutputSerializer esOut(esDescriptor);
esOut.OutputWord(0); //es id
esOut.OutputByte(0); //stream priority
esOut.OutputByte(4); //descriptor type
/*esOut.OutputByte(0x80); //some stuff that no one should probably care about
esOut.OutputByte(0x80);
esOut.OutputByte(0x80);*/
esOut.OutputByte(esDecoderDescriptor.Num());
esOut.Serialize((LPVOID)esDecoderDescriptor.Array(), esDecoderDescriptor.Num());
//.........这里部分代码省略.........