本文整理汇总了C++中FORMAT函数的典型用法代码示例。如果您正苦于以下问题:C++ FORMAT函数的具体用法?C++ FORMAT怎么用?C++ FORMAT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FORMAT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: data_file_t_convert_from
static ssize_t data_file_t_convert_from(data_t *data, fastcall_convert_from *fargs){ // {{{
ssize_t ret;
if(fargs->src == NULL)
return -EINVAL;
switch(fargs->format){
case FORMAT(config):;
case FORMAT(human):;
case FORMAT(native):;
request_t r_config[] = {
{ HK(filename), *fargs->src },
hash_end
};
return file_new((file_t **)&data->ptr, r_config);
case FORMAT(hash):;
hash_t *config;
data_get(ret, TYPE_HASHT, config, fargs->src);
if(ret != 0)
return -EINVAL;
return file_new((file_t **)&data->ptr, config);
default:
break;
};
return -ENOSYS;
} // }}}
开发者ID:shalstvedt,项目名称:frozen,代码行数:30,代码来源:file_t.c
示例2: data_length_t_convert_from
static ssize_t data_length_t_convert_from(data_t *dst, fastcall_convert_from *fargs){ // {{{
ssize_t ret;
length_t *fdata;
if(dst->ptr != NULL)
return -EINVAL;
switch(fargs->format){
case FORMAT(hash):;
hash_t *config;
data_get(ret, TYPE_HASHT, config, fargs->src);
if(ret != 0)
return ret;
if( (fdata = malloc(sizeof(length_t))) == NULL)
return -ENOMEM;
hash_holder_consume(ret, fdata->data, config, HK(data));
if(ret != 0){
free(fdata);
return -EINVAL;
}
fdata->format = FORMAT(clean);
hash_data_get(ret, TYPE_FORMATT, fdata->format, config, HK(format));
dst->ptr = fdata;
return 0;
default:
break;
}
return -ENOSYS;
} // }}}
开发者ID:allisonmobley,项目名称:frozen,代码行数:35,代码来源:length_t.c
示例3: data_env_t_convert_from
/*static ssize_t data_env_t_copy(data_t *src, fastcall_copy *fargs){ // {{{
env_t *fdata = (env_t *)src->ptr;
env_t *new_fdata = NULL;
if(fargs->dest == NULL)
return -EINVAL;
if(fdata){
if( (new_fdata = malloc(sizeof(env_t))) == NULL)
return -EINVAL;
new_fdata->key = fdata->key;
}
fargs->dest->type = src->type;
fargs->dest->ptr = new_fdata;
return 0;
} // }}}*/
static ssize_t data_env_t_convert_from(data_t *dst, fastcall_convert_from *fargs){ // {{{
ssize_t ret;
env_t *fdata;
if(dst->ptr != NULL)
return data_env_t_handler(dst, (fastcall_header *)fargs); // already inited - pass to underlying data
if(fargs->src == NULL)
return -EINVAL;
if( (ret = data_env_t_alloc(dst, NULL)) != 0)
return ret;
fdata = (env_t *)dst->ptr;
switch(fargs->format){
case FORMAT(config):;
case FORMAT(human):;
data_t hkey = DATA_PTR_HASHKEYT(&fdata->key);
fastcall_convert_from r_convert = { { 4, ACTION_CONVERT_FROM }, fargs->src, fargs->format };
return data_query(&hkey, &r_convert);
default:
break;
}
return -ENOSYS;
} // }}}
开发者ID:allisonmobley,项目名称:frozen,代码行数:45,代码来源:env_t.c
示例4: switch
String Object::getString() const
{
switch (this->getNativeType())
{
default:
throw ObjectConversionException(FORMAT("Unknown DataType %u", this->getNativeType()));
case NIL:
return "";
case BOOLEAN:
return this->data.boolean ? "true" : "false";
case NUMBER:
return FORMAT("%f", this->data.number);
case ADDRESS:
return FORMAT("%u", this->data.address);
case STRING:
return this->data.string;
case USERDATA:
{
std::stringstream ss;
ss << this->data.userdata;
return ss.str();
}
}
}
开发者ID:redxdev,项目名称:shogun-old,代码行数:30,代码来源:SVM_Object.cpp
示例5: data_timestamp_t_convert_from
static ssize_t data_timestamp_t_convert_from(data_t *dst, fastcall_convert_from *fargs){ // {{{
char buffer[DEF_BUFFER_SIZE] = { 0 };
timestamp_t *fdata;
if(fargs->src == NULL)
return -EINVAL;
if(dst->ptr == NULL){ // no buffer, alloc new
if(data_timestamp_t_alloc(dst, NULL) != 0)
return -ENOMEM;
}
fdata = (timestamp_t *)dst->ptr;
switch( fargs->format ){
case FORMAT(config):;
case FORMAT(human):;
fastcall_read r_read_str = { { 5, ACTION_READ }, 0, &buffer, sizeof(buffer) - 1 };
if(data_query(fargs->src, &r_read_str) != 0)
return -EFAULT;
return timestamp_from_string(&fdata->time, buffer, r_read_str.buffer_size);
case FORMAT(clean):;
case FORMAT(binary):;
fastcall_read r_read = { { 5, ACTION_READ }, 0, &fdata->time, sizeof(fdata->time) };
return data_query(fargs->src, &r_read);
default:
break;
};
return -ENOSYS;
} // }}}
开发者ID:allisonmobley,项目名称:frozen,代码行数:31,代码来源:main.c
示例6: switch
void TOptions::LogOptions(TLogOptionEvent OnLogOption)
{
for (size_t Index = 0; Index < FOriginalOptions.size(); ++Index)
{
const TOption & Option = FOriginalOptions[Index];
UnicodeString LogStr;
switch (Option.Type)
{
case otParam:
LogStr = FORMAT(L"Parameter: %s", Option.Value.c_str());
assert(Option.Name.IsEmpty());
break;
case otSwitch:
LogStr =
FORMAT(L"Switch: %c%s%s%s",
FSwitchMarks[1], Option.Name.c_str(), (Option.Value.IsEmpty() ? UnicodeString() : FSwitchValueDelimiters.SubString(1, 1)).c_str(), Option.Value.c_str());
break;
default:
FAIL;
break;
}
OnLogOption(LogStr);
}
}
开发者ID:kocicjelena,项目名称:Far-NetBox,代码行数:26,代码来源:Option.cpp
示例7: timestamp_to_string
static ssize_t timestamp_to_string(time_t time, char *string, size_t *string_size, format_t format){ // {{{
ssize_t ret;
intmax_t time_format = -1;
struct tm timetm;
if(gmtime_r(&time, &timetm) == NULL)
return -EINVAL;
switch(format){
case FORMAT(human):
case FORMAT(time_rfc2822): if(time_format == -1) time_format = 0;
case FORMAT(time_rfc3339): if(time_format == -1) time_format = 1;
case FORMAT(time_slash_dmyhms): if(time_format == -1) time_format = 2;
case FORMAT(time_slash_dmyhm): if(time_format == -1) time_format = 3;
case FORMAT(time_slash_dmy): if(time_format == -1) time_format = 4;
case FORMAT(time_dot_dmyhms): if(time_format == -1) time_format = 5;
case FORMAT(time_dot_dmyhm): if(time_format == -1) time_format = 6;
case FORMAT(time_dot_dmy): if(time_format == -1) time_format = 7;
case FORMAT(time_unix): if(time_format == -1) time_format = 8;
default:
if(time_format == -1)
break;
if( (ret = strftime(string, *string_size, time_formats[time_format], &timetm)) == 0)
return -EFAULT;
*string_size = ret;
return 0;
}
return -ENOSYS;
} // }}}
开发者ID:samuell,项目名称:frozen,代码行数:31,代码来源:main.c
示例8: data_timestamp_t_convert_to
static ssize_t data_timestamp_t_convert_to(data_t *src, fastcall_convert_to *fargs){ // {{{
ssize_t ret;
char buffer[DEF_BUFFER_SIZE];
uintmax_t buffer_size = sizeof(buffer);
uintmax_t transfered = 0;
timestamp_t *fdata = (timestamp_t *)src->ptr;
time_t time_val = timestamp_gettime(fdata);
if(fargs->dest == NULL || fdata == NULL)
return -EINVAL;
switch( fargs->format ){
case FORMAT(native):;
case FORMAT(packed):;
fastcall_write r_write = { { 5, ACTION_WRITE }, 0, &time_val, sizeof(time_val) };
ret = data_query(fargs->dest, &r_write);
transfered = r_write.buffer_size;
break;
default:
if( (ret = timestamp_to_string(time_val, buffer, &buffer_size, fargs->format)) != 0)
return ret;
fastcall_write r_write2 = { { 5, ACTION_WRITE }, 0, &buffer, buffer_size };
ret = data_query(fargs->dest, &r_write2);
transfered = r_write.buffer_size;
break;
}
if(fargs->header.nargs >= 5)
fargs->transfered = transfered;
return ret;
} // }}}
开发者ID:samuell,项目名称:frozen,代码行数:33,代码来源:main.c
示例9: FORMAT
//---------------------------------------------------------------------------
UnicodeString __fastcall TPropertiesDialog::LoadRemoteToken(
const TRemoteToken & Token)
{
UnicodeString Result;
if (FUserGroupByID)
{
if (Token.IDValid)
{
if (Token.NameValid)
{
Result = FORMAT(L"%s [%d]", (Token.Name, int(Token.ID)));
}
else
{
Result = FORMAT(L"[%d]", (int(Token.ID)));
}
}
else
{
// be it valid or not
Result = Token.Name;
}
}
else
{
// what if name is not filled in?
Result = Token.Name;
}
return Result;
}
开发者ID:seebigsea,项目名称:winscp,代码行数:31,代码来源:Properties.cpp
示例10: FORMAT
std::string Media::mimetype(Format f) const{
if(f == Track::Vorbis) return "audio/ogg";
if(f == Track::MP3) return "audio/mpeg";
FORMAT(".aiff", "audio/aiff")
FORMAT(".flac", "audio/flac")
FORMAT(".wav", "audio/wav")
return "application/octet-stream";
}
开发者ID:Valodim,项目名称:eqbeats,代码行数:8,代码来源:media.cpp
示例11: data_list_t_convert_to
static ssize_t data_list_t_convert_to(data_t *src, fastcall_convert_to *fargs){ // {{{
ssize_t ret = 0;
ssize_t qret;
list_chunk_t *chunk;
list_t *fdata = (list_t *)src->ptr;
data_t sl_output = DATA_SLIDERT(fargs->dest, 0);
switch(fargs->format){
case FORMAT(packed):;
for(chunk = fdata->head; chunk; chunk = chunk->cnext){
// remove ref_t from top
hash_t r_key[] = {
{ 0, DATA_HASHKEYT(HK(data)) },
hash_end
};
data_t d_key = DATA_PTR_HASHT(r_key);
fastcall_control r_control = {
{ 5, ACTION_CONTROL },
HK(data),
&d_key,
NULL
};
if( (ret = data_query(&chunk->data, &r_control)) < 0)
break;
data_t d_data = DATA_PTR_DATAT(r_control.value);
fastcall_convert_to r_convert = { { 5, ACTION_CONVERT_TO }, &sl_output, FORMAT(packed) };
ret = data_query(&d_data, &r_convert);
data_slider_t_set_offset(&sl_output, r_convert.transfered, SEEK_CUR);
if(ret < 0)
break;
}
// terminate list
data_t terminator = { TYPE_LISTENDT, NULL };
data_t d_data = DATA_PTR_DATAT(&terminator);
fastcall_convert_to r_convert = { { 5, ACTION_CONVERT_TO }, &sl_output, FORMAT(packed) };
qret = data_query(&d_data, &r_convert);
data_slider_t_set_offset(&sl_output, r_convert.transfered, SEEK_CUR);
if(qret < 0)
ret = qret;
break;
default:
return -ENOSYS;
}
if(fargs->header.nargs >= 5)
fargs->transfered = data_slider_t_get_offset(&sl_output);
return ret;
} // }}}
开发者ID:samuell,项目名称:frozen,代码行数:57,代码来源:list_t.c
示例12: result
const NAString QualifiedName::getQualifiedNameAsAnsiNTFilenameString() const
{
// Preallocate a result buffer that'll be big enough most of the time
// (so += won't reallocate+copy most of the time).
NAString result((NASize_T)40, CmpCommon::statementHeap());
NAString catName(CmpCommon::statementHeap());
NAString schName(CmpCommon::statementHeap());
NAString objName(CmpCommon::statementHeap());
formatAsAnsiIdentifier = TRUE; // put quotes on delimited identifiers
if ( NOT getCatalogName().isNull() ) {
catName = FORMAT(getCatalogName());
makeSafeFilenamePart(catName, "SQLMX_DEFAULT_CATALOG_");
}
if ( NOT getSchemaName().isNull() ) {
schName = FORMAT(getSchemaName());
makeSafeFilenamePart(schName, "SQLMX_DEFAULT_SCHEMA_");
}
if ( NOT getObjectName().isNull() ) {
objName = FORMAT(getObjectName());
}
makeSafeFilenamePart(objName, "SQLMX_DEFAULT_FILE_");
formatAsAnsiIdentifier = FALSE; // reset to initial value
size_t totlen = catName.length() + schName.length() + objName.length() + 2;
if ( totlen > 255 ) { // need to truncate
// +1 so round off doesn't give us less than what we need to chop
size_t chopLen = totlen - 255 + 1;
if ( catName.length() - chopLen/2 <= 0 ) // cat too short
schName.remove( schName.length() - chopLen );
else if ( schName.length() - chopLen/2 <= 0 ) // sch too short
catName.remove( catName.length() - chopLen );
else { // chop from both
// remember position starts at 0 and length is 1 more
chopLen /= 2;
catName.remove( catName.length() - chopLen - 1 );
schName.remove( schName.length() - chopLen - 1 );
}
}
if (NOT catName.isNull()) {
result = catName;
result += ".";
}
if (NOT schName.isNull()) {
result += schName;
result += ".";
}
result += objName;
return result;
}
开发者ID:RuoYuHP,项目名称:incubator-trafodion,代码行数:57,代码来源:ObjectNames.cpp
示例13: __checkString
inline int __checkString (const wchar_t* __str)
{
wchar_t* __charIterator;
for (__charIterator = (wchar_t*)__str; *__charIterator; __charIterator++)
{
if (FORMAT(*__charIterator) < START_SYMBOL || FORMAT(*__charIterator) > STOP_SYMBOL)
return 0;
}
return 1;
}
开发者ID:Avi2011class,项目名称:blockhead,代码行数:10,代码来源:b-tree_utf-8.c
示例14: data_uint16_t_convert_from
static ssize_t data_uint16_t_convert_from(data_t *dst, fastcall_convert_from *fargs){ // {{{
ssize_t ret;
char *endptr;
char buffer[DEF_BUFFER_SIZE];
uintmax_t transfered = 0;
if(fargs->src == NULL)
return -EINVAL;
#ifndef OPTIMIZE_UINT
if(dst->ptr == NULL){ // no buffer, alloc new
if( (dst->ptr = malloc(sizeof(uint16_t))) == NULL)
return -ENOMEM;
}
#endif
switch( fargs->format ){
case FORMAT(config):;
case FORMAT(human):; // TODO fix it for slider_t
fastcall_read r_read_str = { { 5, ACTION_READ }, 0, &buffer, sizeof(buffer) - 1 };
if( (ret = data_query(fargs->src, &r_read_str)) < 0){
// TODO memleak
return ret;
}
buffer[r_read_str.buffer_size] = '\0';
SET_TYPE_UINT16T(dst) = (void *)((uintmax_t)((uint16_t )strtoul(buffer, &endptr, 10)));
transfered = (endptr - buffer);
break;
case FORMAT(native):;
case FORMAT(packed):;
if(fargs->src->type == dst->type){
SET_TYPE_UINT16T(dst) = (void *)((uintmax_t) DEREF_TYPE_UINT16T(fargs->src));
ret = 0;
}else{
fastcall_read r_read = { { 5, ACTION_READ }, 0, &buffer, sizeof(uint16_t) };
if( (ret = data_query(fargs->src, &r_read)) < 0){
// TODO memleak
return ret;
}
SET_TYPE_UINT16T(dst) = (void *)((uintmax_t)(*((uint16_t *)buffer)));
}
transfered = sizeof(uint16_t);
break;
default:
return -ENOSYS;
};
if(fargs->header.nargs >= 5)
fargs->transfered = transfered;
return 0;
} // }}}
开发者ID:samuell,项目名称:frozen,代码行数:55,代码来源:uint16_t.c
示例15: geoip_get_info
static void *thread_get_geoloc(void *vargs)
{
struct cb_args *a = (struct cb_args *) vargs;
struct geoip *g = geoip_get_info(a->ip, 0);
enum e_status i_status = a->status;
const char *s_status = a->status & STATUS_AFK ? "AFK" :
i_status & STATUS_PLAYING ? "playing" :
i_status & STATUS_SHOP ? "in shop" :
i_status & STATUS_INVENTORY ? "in inventory" :
i_status & STATUS_ROOM ? "in a room" :
i_status & STATUS_LOBBY ? "in lobby" :
i_status & STATUS_ONLINE ? "connecting" :
"offline"; /* wut ? impossible !§§!§ */
if (a->nick_to == NULL || a->jid_to == NULL)
{
if (g == NULL)
printf("ip:%s is %s\n", a->ip, s_status);
else
{
printf("ip:%s (%s) is %s\n", a->ip, g->country_name, s_status);
geoip_free(g);
}
}
else
{
int r = time(NULL) % 3;
const char *format = r == 0 ? "He's from %s... currently %s" :
r == 1 ? "That's a guy from %s. He is %s" :
"I met him in %s but now he's %s";
char *message;
if (g == NULL)
FORMAT(message, "He's %s", s_status);
else
{
FORMAT(message, format, g->country_name, s_status);
geoip_free(g);
}
xmpp_send_message(a->nick_to, a->jid_to, message);
free(message);
}
free(a->ip);
free(a->nick_to);
free(a->jid_to);
free(a);
pthread_exit(NULL);
}
开发者ID:robertownuk,项目名称:warfacebot,代码行数:54,代码来源:cmd_whois.c
示例16: LOG_META
void ResourceManager::reloadResource(Ogre::ResourceManager* resMgr, const std::string& resourceName, const std::string& resourceGroup)
{
Ogre::ResourcePtr rPtr = resMgr->load(resourceName, resourceGroup);
if (rPtr.isNull()) LOG_META(FORMAT("The resource '%1%' no longer exists!", resourceName));
rPtr->reload();
if (rPtr->isLoaded())
LOG_META(FORMAT("The resource '%1%' wasn`t unloaded!", resourceName));
else
LOG_META(FORMAT("The resource '%1%' was unloaded!", resourceName));
}
开发者ID:Phosfor,项目名称:Pseudoform-2,代码行数:11,代码来源:ResourceManager.cpp
示例17: data_default_convert_from
ssize_t data_default_convert_from (data_t *dest, fastcall_convert_from *fargs){ // {{{
switch(fargs->format){
case FORMAT(native):;
fastcall_convert_to r_convert = { { 3, ACTION_CONVERT_TO }, dest, FORMAT(native) };
return data_query(fargs->src, &r_convert);
default:
break;
}
return -ENOSYS;
} // }}}
开发者ID:shalstvedt,项目名称:frozen,代码行数:11,代码来源:default_t.c
示例18: data_action_t_len
static ssize_t data_action_t_len(data_t *data, fastcall_length *fargs){ // {{{
switch(fargs->format){
case FORMAT(binary):
case FORMAT(clean):
fargs->length = sizeof(action_t);
return 0;
default:
break;
}
return -ENOSYS;
} // }}}
开发者ID:allisonmobley,项目名称:frozen,代码行数:11,代码来源:action_t.c
示例19: TraceDumpToFile
void TraceDumpToFile()
{
if (TraceFile != nullptr)
{
TGuard Guard(TracingCriticalSection);
DWORD Written;
TDateTime N = Now();
#ifdef TRACE_IN_MEMORY_NO_FORMATTING
DWORD Ticks = GetTickCount();
#endif
const UnicodeString TimestampFormat = L"hh:mm:ss.zzz";
UnicodeString TimeString = FormatDateTime(TimestampFormat, N);
UTF8String Buffer = UTF8String(
FORMAT("[%s] Dumping in-memory tracing =================================\n",
(TimeString)));
WriteFile(TraceFile, Buffer.c_str(), Buffer.Length(), &Written, nullptr);
TTracesInMemory::const_iterator i = TracesInMemory.begin();
while (i != TracesInMemory.end())
{
#ifdef TRACE_IN_MEMORY_NO_FORMATTING
const wchar_t * SourceFile = i->SourceFile;
const wchar_t * Slash = wcsrchr(SourceFile, L'\\');
if (Slash != nullptr)
{
SourceFile = Slash + 1;
}
TimeString =
FormatDateTime(TimestampFormat,
IncMilliSecond(N, -static_cast<int>(Ticks - i->Ticks)));
Buffer = UTF8String(FORMAT(L"[%s] [%.4X] [%s:%d:%s] %s\n",
(TimeString, int(i->Thread), SourceFile,
i->Line, i->Func, i->Message)));
WriteFile(TraceFile, Buffer.c_str(), Buffer.Length(), &Written, nullptr);
#else
WriteFile(TraceFile, i->Message.c_str(), i->Message.Length(), &Written, nullptr);
#endif
++i;
}
TracesInMemory.clear();
TimeString = FormatDateTime(TimestampFormat, Now());
Buffer = UTF8String(
FORMAT("[%s] Done in-memory tracing =================================\n",
(TimeString)));
WriteFile(TraceFile, Buffer.c_str(), Buffer.Length(), &Written, nullptr);
}
}
开发者ID:michaellukashov,项目名称:Far-NetBox,代码行数:53,代码来源:Global.cpp
示例20: allocator_new
static ssize_t allocator_new(allocator_fixed_t **pfdata, hash_t *config){ // {{{
ssize_t ret;
data_t *sample;
allocator_fixed_t *fdata;
if((fdata = calloc(1, sizeof(allocator_fixed_t))) == NULL)
return error("calloc failed");
pthread_rwlock_init(&fdata->rwlock, NULL);
// get removed items tracker
hash_holder_consume(ret, fdata->removed_items, config, HK(removed_items));
hash_holder_consume(ret, fdata->storage, config, HK(storage));
if(ret != 0){
ret = error("invalid storage supplied");
goto error;
}
hash_data_get(ret, TYPE_UINTT, fdata->item_size, config, HK(item_size));
if(ret != 0){
if( (sample = hash_data_find(config, HK(item_sample))) == NULL){
ret = error("no item_size nor item_sample supplied");
goto error;
}
fastcall_length r_len = { { 4, ACTION_LENGTH }, 0, FORMAT(binary) };
if( data_query(sample, &r_len) != 0 ){
ret = error("bad item_sample");
goto error;
}
fdata->item_size = r_len.length;
}
if(fdata->item_size == 0){
ret = error("bad item size");
goto error;
}
// get last id
fastcall_length r_len = { { 4, ACTION_LENGTH }, 0, FORMAT(clean) };
if( data_query(&fdata->storage, &r_len) != 0){
ret = error("bad underlying storage");
goto error;
}
fdata->last_id = r_len.length / fdata->item_size;
*pfdata = fdata;
return 0;
error:
allocator_destroy(fdata);
return ret;
} // }}}
开发者ID:allisonmobley,项目名称:frozen,代码行数:53,代码来源:allocator_fixed_t.c
注:本文中的FORMAT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论