本文整理汇总了C++中put_format函数的典型用法代码示例。如果您正苦于以下问题:C++ put_format函数的具体用法?C++ put_format怎么用?C++ put_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了put_format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: save_cylinder_info
static void save_cylinder_info(struct membuffer *b, struct dive *dive)
{
int i, nr;
nr = nr_cylinders(dive);
for (i = 0; i < nr; i++) {
cylinder_t *cylinder = dive->cylinder + i;
int volume = cylinder->type.size.mliter;
const char *description = cylinder->type.description;
int o2 = cylinder->gasmix.o2.permille;
int he = cylinder->gasmix.he.permille;
put_string(b, "cylinder");
if (volume)
put_milli(b, " vol=", volume, "l");
put_pressure(b, cylinder->type.workingpressure, " workpressure=", "bar");
show_utf8(b, " description=", description, "");
strip_mb(b);
if (o2) {
put_format(b, " o2=%u.%u%%", FRACTION(o2, 10));
if (he)
put_format(b, " he=%u.%u%%", FRACTION(he, 10));
}
put_pressure(b, cylinder->start, " start=", "bar");
put_pressure(b, cylinder->end, " end=", "bar");
put_string(b, "\n");
}
}
示例2: save_one_device
static void save_one_device(void *_f, const char *model, uint32_t deviceid,
const char *nickname, const char *serial_nr, const char *firmware)
{
struct membuffer *b = _f;
/* Nicknames that are empty or the same as the device model are not interesting */
if (nickname) {
if (!*nickname || !strcmp(model, nickname))
nickname = NULL;
}
/* Serial numbers that are empty are not interesting */
if (serial_nr && !*serial_nr)
serial_nr = NULL;
/* Firmware strings that are empty are not interesting */
if (firmware && !*firmware)
firmware = NULL;
/* Do we have anything interesting about this dive computer to save? */
if (!serial_nr && !nickname && !firmware)
return;
put_format(b, "<divecomputerid");
show_utf8(b, model, " model='", "'", 1);
put_format(b, " deviceid='%08x'", deviceid);
show_utf8(b, serial_nr, " serial='", "'", 1);
show_utf8(b, firmware, " firmware='", "'", 1);
show_utf8(b, nickname, " nickname='", "'", 1);
put_format(b, "/>\n");
}
示例3: show_utf8
static void show_utf8(struct membuffer *b, const char *prefix, const char *value, const char *postfix)
{
if (value) {
put_format(b, "%s\"", prefix);
quote(b, value);
put_format(b, "\"%s", postfix);
}
}
示例4: save_one_event
static void save_one_event(struct membuffer *b, struct event *ev)
{
put_format(b, " <event time='%d:%02d min'", FRACTION(ev->time.seconds, 60));
show_index(b, ev->type, "type='", "'");
show_index(b, ev->flags, "flags='", "'");
show_index(b, ev->value, "value='", "'");
show_utf8(b, ev->name, " name='", "'", 1);
put_format(b, " />\n");
}
示例5: put_gasmix
static void put_gasmix(struct membuffer *b, struct gasmix *mix)
{
int o2 = mix->o2.permille;
int he = mix->he.permille;
if (o2) {
put_format(b, " o2='%u.%u%%'", FRACTION(o2, 10));
if (he)
put_format(b, " he='%u.%u%%'", FRACTION(he, 10));
}
}
示例6: show_date
static void show_date(struct membuffer *b, timestamp_t when)
{
struct tm tm;
utc_mkdate(when, &tm);
put_format(b, "date %04u-%02u-%02u\n",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
put_format(b, "time %02u:%02u:%02u\n",
tm.tm_hour, tm.tm_min, tm.tm_sec);
}
示例7: create_dive_name
/*
* The name of a dive is the date and the dive number (and possibly
* the uniqueness suffix).
*
* Note that the time of the dive may not be the same as the
* time of the directory structure it is created in: the dive
* might be part of a trip that straddles a month (or even a
* year).
*
* We do *not* want to use localized weekdays and cause peoples save
* formats to depend on their locale.
*/
static void create_dive_name(struct dive *dive, struct membuffer *name, struct tm *dirtm)
{
struct tm tm;
static const char weekday[7][4] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
utc_mkdate(dive->when, &tm);
if (tm.tm_year != dirtm->tm_year)
put_format(name, "%04u-", tm.tm_year + 1900);
if (tm.tm_mon != dirtm->tm_mon)
put_format(name, "%02u-", tm.tm_mon+1);
put_format(name, "%02u-%s-%02u:%02u:%02u",
tm.tm_mday, weekday[tm.tm_wday],
tm.tm_hour, tm.tm_min, tm.tm_sec);
}
示例8: save_dives_buffer
void save_dives_buffer(struct membuffer *b, const bool select_only)
{
int i;
struct dive *dive;
dive_trip_t *trip;
put_format(b, "<divelog program='subsurface' version='%d'>\n<settings>\n", VERSION);
if (prefs.save_userid_local)
put_format(b, " <userid>%s</userid>\n", prefs.userid);
/* save the dive computer nicknames, if any */
call_for_each_dc(b, save_one_device);
if (autogroup)
put_format(b, " <autogroup state='1' />\n");
put_format(b, "</settings>\n<dives>\n");
for (trip = dive_trip_list; trip != NULL; trip = trip->next)
trip->index = 0;
/* save the dives */
for_each_dive(i, dive) {
if (select_only) {
if (!dive->selected)
continue;
save_one_dive(b, dive);
} else {
trip = dive->divetrip;
/* Bare dive without a trip? */
if (!trip) {
save_one_dive(b, dive);
continue;
}
/* Have we already seen this trip (and thus saved this dive?) */
if (trip->index)
continue;
/* We haven't seen this trip before - save it and all dives */
trip->index = 1;
save_trip(b, trip);
}
}
put_format(b, "</dives>\n</divelog>\n");
}
示例9: put_milli
void put_milli(struct membuffer *b, const char *pre, int value, const char *post)
{
int i;
char buf[4];
const char *sign = "";
unsigned v;
v = value;
if (value < 0) {
sign = "-";
v = -value;
}
for (i = 2; i >= 0; i--) {
buf[i] = (v % 10) + '0';
v /= 10;
}
buf[3] = 0;
if (buf[2] == '0') {
buf[2] = 0;
if (buf[1] == '0')
buf[1] = 0;
}
put_format(b, "%s%s%u.%s%s", pre, sign, v, buf, post);
}
示例10: create_trip_name
static void create_trip_name(dive_trip_t *trip, struct membuffer *name, struct tm *tm)
{
put_format(name, "%02u-", tm->tm_mday);
if (trip->location) {
char ascii_loc[MAXTRIPNAME+1], *p = trip->location;
int i;
for (i = 0; i < MAXTRIPNAME; ) {
char c = *p++;
switch (c) {
case 0:
case ',':
case '.':
break;
case 'a' ... 'z':
case 'A' ... 'Z':
ascii_loc[i++] = c;
continue;
default:
continue;
}
break;
}
if (i > 1) {
put_bytes(name, ascii_loc, i);
return;
}
}
示例11: save_one_event
static void save_one_event(struct membuffer *b, struct event *ev)
{
put_format(b, " <event time='%d:%02d min'", FRACTION(ev->time.seconds, 60));
show_index(b, ev->type, "type='", "'");
show_index(b, ev->flags, "flags='", "'");
show_index(b, ev->value, "value='", "'");
show_utf8(b, ev->name, " name='", "'", 1);
if (event_is_gaschange(ev)) {
if (ev->gas.index >= 0) {
show_index(b, ev->gas.index, "cylinder='", "'");
put_gasmix(b, &ev->gas.mix);
} else if (!event_gasmix_redundant(ev))
put_gasmix(b, &ev->gas.mix);
}
put_format(b, " />\n");
}
示例12: save_weightsystem_info
static void save_weightsystem_info(struct membuffer *b, struct dive *dive)
{
int i, nr;
nr = nr_weightsystems(dive);
for (i = 0; i < nr; i++) {
weightsystem_t *ws = dive->weightsystem + i;
int grams = ws->weight.grams;
const char *description = ws->description;
put_format(b, " <weightsystem");
put_milli(b, " weight='", grams, " kg'");
show_utf8(b, description, " description='", "'", 1);
put_format(b, " />\n");
}
}
示例13: put_duration
int put_duration(struct membuffer *b, duration_t duration, const char *pre, const char *post)
{
if (!duration.seconds)
return 0;
put_format(b, "%s%u:%02u%s", pre, FRACTION(duration.seconds, 60), post);
return 1;
}
示例14: put_salinity
int put_salinity(struct membuffer *b, int salinity, const char *pre, const char *post)
{
if (!salinity)
return 0;
put_format(b, "%s%d%s", pre, salinity / 10, post);
return 1;
}
示例15: writeMarkers
void writeMarkers(struct membuffer *b, const bool selected_only)
{
int i, dive_no = 0;
struct dive *dive;
char pre[1000], post[1000];
for_each_dive (i, dive) {
if (selected_only) {
if (!dive->selected)
continue;
}
struct dive_site *ds = get_dive_site_for_dive(dive);
if (!ds || !dive_site_has_gps_location(ds))
continue;
put_degrees(b, ds->latitude, "temp = new google.maps.Marker({position: new google.maps.LatLng(", "");
put_degrees(b, ds->longitude, ",", ")});\n");
put_string(b, "markers.push(temp);\ntempinfowindow = new google.maps.InfoWindow({content: '<div id=\"content\">'+'<div id=\"siteNotice\">'+'</div>'+'<div id=\"bodyContent\">");
snprintf(pre, sizeof(pre), "<p>%s ", translate("gettextFromC", "Date:"));
put_HTML_date(b, dive, pre, "</p>");
snprintf(pre, sizeof(pre), "<p>%s ", translate("gettextFromC", "Time:"));
put_HTML_time(b, dive, pre, "</p>");
snprintf(pre, sizeof(pre), "<p>%s ", translate("gettextFromC", "Duration:"));
snprintf(post, sizeof(post), " %s</p>", translate("gettextFromC", "min"));
put_duration(b, dive->duration, pre, post);
put_string(b, "<p> ");
put_HTML_quoted(b, translate("gettextFromC", "Max. depth:"));
put_HTML_depth(b, dive, " ", "</p>");
put_string(b, "<p> ");
put_HTML_quoted(b, translate("gettextFromC", "Air temp.:"));
put_HTML_airtemp(b, dive, " ", "</p>");
put_string(b, "<p> ");
put_HTML_quoted(b, translate("gettextFromC", "Water temp.:"));
put_HTML_watertemp(b, dive, " ", "</p>");
snprintf(pre, sizeof(pre), "<p>%s <b>", translate("gettextFromC", "Location:"));
put_string(b, pre);
put_HTML_quoted(b, get_dive_location(dive));
put_string(b, "</b></p>");
snprintf(pre, sizeof(pre), "<p> %s ", translate("gettextFromC", "Notes:"));
put_HTML_notes(b, dive, pre, " </p>");
put_string(b, "</p>'+'</div>'+'</div>'});\ninfowindows.push(tempinfowindow);\n");
put_format(b, "google.maps.event.addListener(markers[%d], 'mouseover', function() {\ninfowindows[%d].open(map,markers[%d]);}", dive_no, dive_no, dive_no);
put_format(b, ");google.maps.event.addListener(markers[%d], 'mouseout', function() {\ninfowindows[%d].close();});\n", dive_no, dive_no);
dive_no++;
}
}