本文整理汇总了C++中read_float函数的典型用法代码示例。如果您正苦于以下问题:C++ read_float函数的具体用法?C++ read_float怎么用?C++ read_float使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_float函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: load
static void load(Space *s, uint8_t old_type, int32_t &addr) {
if (!s->setup_nums(3, 3)) {
debug("Failed to set up delta axes");
s->cancel_update();
return;
}
for (uint8_t a = 0; a < 3; ++a) {
APEX(s, a).axis_min = read_float(addr);
APEX(s, a).axis_max = read_float(addr);
APEX(s, a).rodlength = read_float(addr);
APEX(s, a).radius = read_float(addr);
}
PRIVATE(s).angle = read_float(addr);
if (isinf(PRIVATE(s).angle) || isnan(PRIVATE(s).angle))
PRIVATE(s).angle = 0;
#define sin210 -.5
#define cos210 -0.8660254037844386 // .5*sqrt(3)
#define sin330 -.5
#define cos330 0.8660254037844386 // .5*sqrt(3)
#define sin90 1
// Coordinates of axes (at angles 210, 330, 90; each with its own radius).
double x[3], y[3];
x[0] = APEX(s, 0).radius * cos210;
y[0] = APEX(s, 0).radius * sin210;
x[1] = APEX(s, 1).radius * cos330;
y[1] = APEX(s, 1).radius * sin330;
x[2] = 0;
y[2] = APEX(s, 2).radius * sin90;
for (uint8_t a = 0; a < 3; ++a) {
APEX(s, a).x = x[a] * cos(PRIVATE(s).angle) - y[a] * sin(PRIVATE(s).angle);
APEX(s, a).y = y[a] * cos(PRIVATE(s).angle) + x[a] * sin(PRIVATE(s).angle);
APEX(s, a).z = sqrt(APEX(s, a).rodlength * APEX(s, a).rodlength - APEX(s, a).radius * APEX(s, a).radius);
}
}
开发者ID:plastbotindustries,项目名称:franklin,代码行数:34,代码来源:type-delta.cpp
示例2: settings_execute_line
// Parameter lines are on the form '$4=374.3' or '$' to dump current settings
uint8_t settings_execute_line(char *line) {
uint8_t char_counter = 1;
float parameter, value;
if(line[0] != '$') {
return (STATUS_UNSUPPORTED_STATEMENT);
}
if(!line[char_counter]) {
settings_dump();
return (STATUS_OK);
}
if(!read_float(line, &char_counter, ¶meter)) {
return(STATUS_BAD_NUMBER_FORMAT);
};
if(line[char_counter++] != '=') {
return (STATUS_UNSUPPORTED_STATEMENT);
}
if(!read_float(line, &char_counter, &value)) {
return(STATUS_BAD_NUMBER_FORMAT);
}
if(line[char_counter] != 0) {
return (STATUS_UNSUPPORTED_STATEMENT);
}
settings_store_setting(parameter, value);
return (STATUS_OK);
}
开发者ID:csdexter,项目名称:grbl,代码行数:27,代码来源:settings.c
示例3: loaddebug
void Space::load_axis(uint8_t a, int32_t &addr) { // {{{
loaddebug("loading axis %d", a);
axis[a]->park = read_float(addr);
axis[a]->park_order = read_8(addr);
axis[a]->min_pos = read_float(addr);
axis[a]->max_pos = read_float(addr);
} // }}}
开发者ID:LaVagabond,项目名称:franklin,代码行数:7,代码来源:space.cpp
示例4: main
int main(int argc, char *argv[])
{
float curr;
float full;
for(int i = 0; i < argc; i++)
{/* Arguments passed to the
program will be parsed here. */
if(strcmp(argv[i], "-n") == 0)
{/* Set the newline boolean. */
newline = false;
continue;
}
if(strcmp(argv[i], "-b") == 0)
{/* Set the colour boolean. */
colour = false;
continue;
}
}
read_float(PATH "charge_now", &curr);
read_float(PATH "charge_full", &full);
print_percentage(
calculate_percentage(curr, full));
return EXIT_SUCCESS;
}
开发者ID:henrikhasell,项目名称:battery-monitor,代码行数:28,代码来源:battery.c
示例5: loaddebug
void Space::load_motor(int m, int32_t &addr) { // {{{
loaddebug("loading motor %d", m);
uint16_t enable = motor[m]->enable_pin.write();
double old_home_pos = motor[m]->home_pos;
double old_steps_per_unit = motor[m]->steps_per_unit;
motor[m]->step_pin.read(read_16(addr));
motor[m]->dir_pin.read(read_16(addr));
motor[m]->enable_pin.read(read_16(addr));
motor[m]->limit_min_pin.read(read_16(addr));
motor[m]->limit_max_pin.read(read_16(addr));
motor[m]->steps_per_unit = read_float(addr);
motor[m]->home_pos = read_float(addr);
motor[m]->limit_v = read_float(addr);
motor[m]->limit_a = read_float(addr);
motor[m]->home_order = read_8(addr);
arch_motors_change();
SET_OUTPUT(motor[m]->enable_pin);
if (enable != motor[m]->enable_pin.write()) {
if (motors_busy)
SET(motor[m]->enable_pin);
else {
RESET(motor[m]->enable_pin);
}
}
RESET(motor[m]->step_pin);
SET_INPUT(motor[m]->limit_min_pin);
SET_INPUT(motor[m]->limit_max_pin);
bool must_move = false;
if (!isnan(motor[m]->home_pos)) {
// Axes with a limit switch.
if (motors_busy && (old_home_pos != motor[m]->home_pos || old_steps_per_unit != motor[m]->steps_per_unit) && !isnan(old_home_pos)) {
double ohp = old_home_pos * old_steps_per_unit;
double hp = motor[m]->home_pos * motor[m]->steps_per_unit;
double diff = hp - ohp;
motor[m]->settings.current_pos += diff;
//debug("load motor %d %d new home %f add %f", id, m, motor[m]->home_pos, diff);
arch_addpos(id, m, diff);
must_move = true;
}
}
else {
// Axes without a limit switch, including extruders.
if (motors_busy && old_steps_per_unit != motor[m]->steps_per_unit) {
debug("load motor %d %d new steps no home", id, m);
double oldpos = motor[m]->settings.current_pos;
double pos = oldpos / old_steps_per_unit;
motor[m]->settings.current_pos = pos * motor[m]->steps_per_unit;
arch_addpos(id, m, motor[m]->settings.current_pos - oldpos);
// Adjust current_pos in all history.
for (int h = 0; h < FRAGMENTS_PER_BUFFER; ++h) {
oldpos = motor[m]->history[h].current_pos;
pos = oldpos / old_steps_per_unit;
motor[m]->history[h].current_pos = pos * motor[m]->steps_per_unit;
}
}
}
if (must_move)
move_to_current();
} // }}}
开发者ID:yanggen,项目名称:franklin,代码行数:59,代码来源:space.cpp
示例6: getSize
size_t PerspectiveMessage::deserialize(unsigned char *const read_buffer) {
size_t len = getSize();
read_float(read_buffer, 12, &_perspective._fov);
read_float(read_buffer, 16, &_perspective._aspect);
read_float(read_buffer, 20, &_perspective._near);
read_float(read_buffer, 24, &_perspective._far);
return len;
}
开发者ID:Jeff885,项目名称:RemoteRenderer,代码行数:8,代码来源:Message.cpp
示例7: loaddebug
void Space::load_motor(uint8_t m, int32_t &addr) { // {{{
loaddebug("loading motor %d", m);
uint16_t enable = motor[m]->enable_pin.write();
double old_home_pos = motor[m]->home_pos;
double old_steps_per_unit = motor[m]->steps_per_unit;
motor[m]->step_pin.read(read_16(addr));
motor[m]->dir_pin.read(read_16(addr));
motor[m]->enable_pin.read(read_16(addr));
motor[m]->limit_min_pin.read(read_16(addr));
motor[m]->limit_max_pin.read(read_16(addr));
motor[m]->sense_pin.read(read_16(addr));
motor[m]->steps_per_unit = read_float(addr);
motor[m]->max_steps = read_8(addr);
motor[m]->home_pos = read_float(addr);
motor[m]->limit_v = read_float(addr);
motor[m]->limit_a = read_float(addr);
motor[m]->home_order = read_8(addr);
arch_motors_change();
SET_OUTPUT(motor[m]->enable_pin);
if (enable != motor[m]->enable_pin.write()) {
if (motors_busy)
SET(motor[m]->enable_pin);
else {
RESET(motor[m]->enable_pin);
}
}
RESET(motor[m]->step_pin);
SET_INPUT(motor[m]->limit_min_pin);
SET_INPUT(motor[m]->limit_max_pin);
SET_INPUT(motor[m]->sense_pin);
bool must_move = false;
if (!isnan(motor[m]->home_pos)) {
// Axes with a limit switch.
if (motors_busy && (old_home_pos != motor[m]->home_pos || old_steps_per_unit != motor[m]->steps_per_unit) && !isnan(old_home_pos)) {
int32_t hp = motor[m]->home_pos * motor[m]->steps_per_unit + (motor[m]->home_pos > 0 ? .49 : -.49);
int32_t ohp = old_home_pos * old_steps_per_unit + (old_home_pos > 0 ? .49 : -.49);
int32_t diff = hp - ohp;
motor[m]->settings.current_pos += diff;
cpdebug(id, m, "load motor new home add %d", diff);
arch_addpos(id, m, diff);
must_move = true;
}
}
else {
// Axes without a limit switch, including extruders.
if (motors_busy && old_steps_per_unit != motor[m]->steps_per_unit) {
int32_t cp = motor[m]->settings.current_pos;
double pos = cp / old_steps_per_unit;
cpdebug(id, m, "load motor new steps no home");
motor[m]->settings.current_pos = pos * motor[m]->steps_per_unit;
int diff = motor[m]->settings.current_pos - cp;
arch_addpos(id, m, diff);
}
}
if (must_move)
move_to_current();
} // }}}
开发者ID:plastbotindustries,项目名称:franklin,代码行数:57,代码来源:space.cpp
示例8: read_float
//---------------------------------------------------------------------------------------------
Vec3 BitMessage::read_vec3() const
{
Vec3 v;
v.x = read_float();
v.y = read_float();
v.z = read_float();
return v;
}
开发者ID:BasileusOnTop,项目名称:warzone-dcc,代码行数:11,代码来源:BitMessage.cpp
示例9: gain_menu_branch
void gain_menu_branch(uint8_t com_type){
switch(com_type){
case DISPLAY:
uart0_printf("P: %f, I: %f, D: %f\r\n", c_gain->p_gain, c_gain->i_gain, c_gain->d_gain);
break;
case SET_P:
uart0_printf("P Gain is %f, input new value.\r\n", c_gain->p_gain);
c_gain->p_gain = uart0_get_float_input();
break;
case SET_I:
uart0_printf("I Gain is %f, input new value.\r\n", c_gain->i_gain);
c_gain->i_gain = uart0_get_float_input();
break;
case SET_D:
uart0_printf("D Gain is %f, input new value.\r\n", c_gain->d_gain);
c_gain->d_gain = uart0_get_float_input();
break;
case SET_Q_TH:
uart0_printf("OF quality threshold is %d, input new value. (range: 0~255)\r\n", c_flow->qual_th);
c_flow->qual_th = (uint16_t)uart0_get_float_input();
if(c_flow->qual_th > 255) c_flow->qual_th = 255;
break;
case SAVE:
write_float(P_ADD, c_gain->p_gain);
write_float(I_ADD, c_gain->i_gain);
write_float(D_ADD, c_gain->d_gain);
write_uint16(Q_TH_ADD, c_flow->qual_th);
uart0_printf("Saved!\r\n");
break;
case RESTORE:
c_gain->p_gain = read_float(P_ADD);
c_gain->i_gain = read_float(I_ADD);
c_gain->d_gain = read_float(D_ADD);
uart0_printf("Restore Parameters.\r\n");
break;
case EXIT:
menu_flg = 0;
input_detect = 0;
top_menu();
break;
default:
uart0_printf("invalid command\r\n");
input_detect = 0;
break;
}
}
开发者ID:shinji0803,项目名称:FM3_old_dev,代码行数:55,代码来源:console.c
示例10: read_pnts
static void read_pnts(FILE *f, int nbytes, lwObject *lwo)
{
int i;
lwo->vertex_cnt = nbytes / 12;
lwo->vertex = (float*) calloc(sizeof(GLfloat)*lwo->vertex_cnt*3, 1);
for (i=0; i<lwo->vertex_cnt; i++) {
lwo->vertex[i*3+0] = read_float(f);
lwo->vertex[i*3+1] = read_float(f);
lwo->vertex[i*3+2] = read_float(f);
}
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:11,代码来源:lw.cpp
示例11: load_ambdec_speakers
static int load_ambdec_speakers(AmbDecConf *conf, FILE *f, char **buffer, size_t *maxlen, char **saveptr)
{
ALuint cur = 0;
while(cur < conf->NumSpeakers)
{
const char *cmd = my_strtok_r(NULL, " \t", saveptr);
if(!cmd)
{
char *line = read_clipped_line(f, buffer, maxlen);
if(!line)
{
ERR("Unexpected end of file\n");
return 0;
}
cmd = my_strtok_r(line, " \t", saveptr);
}
if(strcmp(cmd, "add_spkr") == 0)
{
const char *name = my_strtok_r(NULL, " \t", saveptr);
const char *dist = my_strtok_r(NULL, " \t", saveptr);
const char *az = my_strtok_r(NULL, " \t", saveptr);
const char *elev = my_strtok_r(NULL, " \t", saveptr);
const char *conn = my_strtok_r(NULL, " \t", saveptr);
if(!name) WARN("Name not specified for speaker %u\n", cur+1);
else al_string_copy_cstr(&conf->Speakers[cur].Name, name);
if(!dist) WARN("Distance not specified for speaker %u\n", cur+1);
else read_float(&conf->Speakers[cur].Distance, dist);
if(!az) WARN("Azimuth not specified for speaker %u\n", cur+1);
else read_float(&conf->Speakers[cur].Azimuth, az);
if(!elev) WARN("Elevation not specified for speaker %u\n", cur+1);
else read_float(&conf->Speakers[cur].Elevation, elev);
if(!conn) TRACE("Connection not specified for speaker %u\n", cur+1);
else al_string_copy_cstr(&conf->Speakers[cur].Connection, conn);
cur++;
}
else
{
ERR("Unexpected speakers command: %s\n", cmd);
return 0;
}
cmd = my_strtok_r(NULL, " \t", saveptr);
if(cmd)
{
ERR("Unexpected junk on line: %s\n", cmd);
return 0;
}
}
return 1;
}
开发者ID:rudi-c,项目名称:procedural-terrain-488,代码行数:54,代码来源:ambdec.c
示例12: set_line_style_by_UL
void set_line_style_by_UL()
{
SCHAR index, pos_index, neg_index, count, i;
double factor, percentage;
float tmp;
if (read_float(&tmp)) {
set_line_style_defaults(); /* reset to defaults */
return;
} else {
index = (int) tmp;
}
pos_index = index - LT_MIN;
neg_index = (index * -1) - LT_MIN;
for (count = 0, percentage = 0; (read_float(&tmp) == 0); count++) { /* while there is an argument */
lt[pos_index][count] = (double) tmp;
percentage += (int) tmp;
}
lt[pos_index][count] = -1;
if (fabs(percentage - 100.) > 0.5) {
factor = 100.0 / percentage;
for (count = 0; count < LT_ELEMENTS; count++) {
if (lt[pos_index][count] < 0) {
break;
} else {
lt[pos_index][count] *= factor;
}
}
}
/* now derive the adaptive version */
count--;
if (count % 2) { /* last value denotes a gap */
lt[neg_index][0] = lt[pos_index][0] / 2;
for (i = 1; i <= count; i++)
lt[neg_index][i] = lt[pos_index][i];
lt[neg_index][count + 1] = lt[pos_index][0] / 2;
lt[neg_index][count + 2] = -1;
} else { /* last value denotes a line */
lt[neg_index][0] =
(lt[pos_index][0] + lt[pos_index][count]) / 2;
for (i = 1; i < count; i++)
lt[neg_index][i] = lt[pos_index][i];
lt[neg_index][count] = lt[neg_index][0];
lt[neg_index][count + 1] = -1;
}
}
开发者ID:bug400,项目名称:lifutils,代码行数:53,代码来源:lindef.c
示例13: set_line_attr
void set_line_attr(FILE * hd)
{
float ftmp1;
float ftmp2;
/* LineEnds itmp;*/
int itmp;
if (read_float(&ftmp1, hd)) { /* No kind found */
set_line_attr_defaults();
return;
}
for (;;) {
if (read_float(&ftmp2, hd)) { /* No value found */
/* do_error */
return;
}
itmp = (int) ftmp2;
PlotCmd_to_tmpfile(DEF_LA);
switch ((int) ftmp1) {
case 1:
if ((itmp >= LAE_butt) && (itmp <= LAE_round)) {
Line_Attr_to_tmpfile(LineAttrEnd, itmp);
} else {
Line_Attr_to_tmpfile(LineAttrEnd,
LAE_butt);
}
break;
case 2:
if ((itmp >= LAJ_plain_miter)
&& (itmp <= LAJ_nojoin)) {
Line_Attr_to_tmpfile(LineAttrJoin, itmp);
} else {
Line_Attr_to_tmpfile(LineAttrJoin,
LAJ_plain_miter);
}
break;
case 3:
Line_Attr_to_tmpfile(LineAttrLimit, itmp);
break;
}
if (read_float(&ftmp1, hd)) { /* No kind found */
return;
}
}
return;
}
开发者ID:myopensourceprojects,项目名称:hp2xx-3.4.4,代码行数:51,代码来源:lindef.c
示例14: load_volume
Volume* load_volume(tinyxml2::XMLElement *elem, VolumeCache &cache, const std::string &scene_file){
if (!elem->Attribute("name")){
std::cout << "Scene error: Volumes require a name" << std::endl;
return nullptr;
}
if (!elem->Attribute("type")){
std::cout << "Scene error: Volumes require a type" << std::endl;
return nullptr;
}
std::string name = elem->Attribute("name");
std::string type = elem->Attribute("type");
Volume *vol = cache.get(name);
if (vol){
return vol;
}
Colorf sig_a, sig_s, emit;
float phase_asym;
read_color(elem->FirstChildElement("absorption"), sig_a);
read_color(elem->FirstChildElement("scattering"), sig_s);
read_color(elem->FirstChildElement("emission"), emit);
read_float(elem->FirstChildElement("phase_asymmetry"), phase_asym);
if (type == "homogeneous"){
Point min, max;
read_point(elem->FirstChildElement("min"), min);
read_point(elem->FirstChildElement("max"), max);
return cache.add(name, std::make_unique<HomogeneousVolume>(sig_a, sig_s, emit, phase_asym, BBox{min, max}));
}
if (type == "exponential"){
float a = 0, b = 0;
Vector up;
Point min, max;
read_float(elem->FirstChildElement("a"), a);
read_float(elem->FirstChildElement("b"), b);
read_vector(elem->FirstChildElement("up"), up);
read_point(elem->FirstChildElement("min"), min);
read_point(elem->FirstChildElement("max"), max);
return cache.add(name, std::make_unique<ExponentialVolume>(sig_a, sig_s, emit, phase_asym, BBox{min, max}, a, b, up));
}
if (type == "vol"){
std::string file = scene_file.substr(0, scene_file.rfind(PATH_SEP) + 1) + elem->Attribute("file");
float density_scale = 1;
read_float(elem->FirstChildElement("density_scale"), density_scale);
return cache.add(name, std::make_unique<GridVolume>(sig_a, sig_s, emit, phase_asym, file, density_scale));
}
std::cout << "Scene error: Unrecognized volume type " << type << std::endl;
return nullptr;
}
开发者ID:Twinklebear,项目名称:tray,代码行数:50,代码来源:load_volume.cpp
示例15: read_value
static struct value *
read_value(struct _field *f, struct atom * a, uint8_t *buffer) {
struct value * v;
switch (f->type) {
case PTYPE_DOUBLE:
v = malloc(SIZE_VAR);
v->v.var->real = read_double(a);
break;
case PTYPE_FLOAT:
v = malloc(SIZE_VAR);
v->v.var->real = (double) read_float(a);
break;
case PTYPE_ENUM:
v = malloc(SIZE_VAR);
v->v.var->e.id = a->v.i.low;
v->v.var->e.name = _pbcM_ip_query(f->type_name.e->id , a->v.i.low);
break;
case PTYPE_INT64:
case PTYPE_UINT64:
case PTYPE_INT32:
case PTYPE_UINT32:
case PTYPE_FIXED32:
case PTYPE_FIXED64:
case PTYPE_SFIXED32:
case PTYPE_SFIXED64:
case PTYPE_BOOL:
v = malloc(SIZE_VAR);
v->v.var->integer = a->v.i;
break;
case PTYPE_SINT32:
v = malloc(SIZE_VAR);
v->v.var->integer = a->v.i;
varint_dezigzag32(&(v->v.var->integer));
break;
case PTYPE_SINT64:
v = malloc(SIZE_VAR);
v->v.var->integer = a->v.i;
varint_dezigzag64(&(v->v.var->integer));
break;
case PTYPE_STRING:
v = read_string(a,f,buffer);
break;
case PTYPE_BYTES:
v = malloc(SIZE_VAR);
v->v.var->s.str = (const char *)(buffer + a->v.s.start);
v->v.var->s.len = a->v.s.end - a->v.s.start;
break;
case PTYPE_MESSAGE:
v = malloc(SIZE_MESSAGE);
_pbc_rmessage_new(&(v->v.message), f->type_name.m ,
buffer + a->v.s.start ,
a->v.s.end - a->v.s.start);
break;
default:
return NULL;
}
v->type = f;
return v;
}
开发者ID:kelvinyu,项目名称:pbc,代码行数:60,代码来源:rmessage.c
示例16: unpack_field
static int
unpack_field(int ctype, int ptype, char * buffer, struct atom * a, void *out) {
if (ctype == CTYPE_ARRAY) {
return unpack_array(ptype, buffer, a , out);
}
if (ctype == CTYPE_PACKED) {
pbc_ctx packed;
struct context * ctx = (struct context *)packed;
int n = _pbcC_open_packed(packed , ptype,
(uint8_t *)buffer + a->v.s.start, a->v.s.end - a->v.s.start);
if (n<=0)
return -1;
int i;
int r =0;
for (i=0;i<n;i++) {
r |= unpack_array(ptype , buffer , &(ctx->a[i]) , out);
}
if (r)
return -1;
return 0;
}
switch(ptype) {
case PTYPE_DOUBLE:
return write_real(ctype, read_double(a), out);
case PTYPE_FLOAT:
return write_real(ctype, read_float(a), out);
case PTYPE_INT64:
case PTYPE_UINT64:
case PTYPE_INT32:
case PTYPE_UINT32:
case PTYPE_FIXED32:
case PTYPE_FIXED64:
case PTYPE_SFIXED32:
case PTYPE_SFIXED64:
case PTYPE_ENUM: // enum must be integer type in pattern mode
case PTYPE_BOOL:
return write_integer(ctype, a , out);
case PTYPE_SINT32: {
struct longlong temp = a->v.i;
varint_dezigzag32(&temp);
return write_longlong(ctype, &temp , out);
}
case PTYPE_SINT64: {
struct longlong temp = a->v.i;
varint_dezigzag64(&temp);
return write_longlong(ctype, &temp , out);
}
case PTYPE_MESSAGE:
((union _pbc_var *)out)->m.buffer = buffer + a->v.s.start;
((union _pbc_var *)out)->m.len = a->v.s.end - a->v.s.start;
return 0;
case PTYPE_STRING:
((union _pbc_var *)out)->s.str = buffer + a->v.s.start;
((union _pbc_var *)out)->s.len = a->v.s.end - a->v.s.start;
return 0;
}
return -1;
}
开发者ID:justnull,项目名称:pbc,代码行数:59,代码来源:pattern.c
示例17: load
static void load(Space *s, uint8_t old_type, int32_t &addr) {
if (!s->setup_nums(3, 3)) {
debug("Failed to set up polar axes");
s->cancel_update();
return;
}
PRIVATE(s).max_r = read_float(addr);
}
开发者ID:ddparker,项目名称:franklin,代码行数:8,代码来源:type-polar.cpp
示例18: push_value_array
static void
push_value_array(pbc_array array, struct _field *f, struct atom * a, uint8_t *buffer) {
pbc_var v;
switch (f->type) {
case PTYPE_DOUBLE:
v->real = read_double(a);
break;
case PTYPE_FLOAT:
v->real = (double) read_float(a);
break;
case PTYPE_ENUM:
v->e.id = a->v.i.low;
v->e.name = _pbcM_ip_query(f->type_name.e->id , a->v.i.low);
break;
case PTYPE_INT64:
case PTYPE_UINT64:
case PTYPE_INT32:
case PTYPE_UINT32:
case PTYPE_FIXED32:
case PTYPE_FIXED64:
case PTYPE_SFIXED32:
case PTYPE_SFIXED64:
case PTYPE_BOOL:
v->integer = a->v.i;
break;
case PTYPE_SINT32:
v->integer = a->v.i;
varint_dezigzag32(&(v->integer));
break;
case PTYPE_SINT64:
v->integer = a->v.i;
varint_dezigzag64(&(v->integer));
break;
case PTYPE_STRING:
read_string_var(v,a,f,buffer);
break;
case PTYPE_BYTES:
v->s.str = (const char *)(buffer + a->v.s.start);
v->s.len = a->v.s.end - a->v.s.start;
break;
case PTYPE_MESSAGE: {
struct pbc_rmessage message;
_pbc_rmessage_new(&message, f->type_name.m ,
buffer + a->v.s.start ,
a->v.s.end - a->v.s.start);
if (message.msg == NULL)
return;
v->p[0] = message.msg;
v->p[1] = message.index;
break;
}
default:
return;
}
_pbcA_push(array,v);
}
开发者ID:kelvinyu,项目名称:pbc,代码行数:58,代码来源:rmessage.c
示例19: read_cd
/*
* read_cd()
*
* Read in from the keyboard the details of one CD
*/
void read_cd(cd_t *cd)
{
read_string("Title? ", cd->title, sizeof cd->title);
#ifndef NOARTIST
read_string("Artist? ", cd->artist, sizeof cd->artist);
#endif
cd->tracks = read_int("Number of tracks? ");
cd->album = yesno("Is the CD an Album");
cd->price = read_float("Retail price (e.g. 4.65)? ");
}
开发者ID:NoMan2000,项目名称:c-prog,代码行数:15,代码来源:INPUT.C
示例20: read_field
static void read_field(FILE *f, const save_field_t *field, void *base)
{
void *p = (byte *)base + field->ofs;
int i;
switch (field->type) {
case F_BYTE:
read_data(p, field->size, f);
break;
case F_SHORT:
for (i = 0; i < field->size; i++) {
((short *)p)[i] = read_short(f);
}
break;
case F_INT:
for (i = 0; i < field->size; i++) {
((int *)p)[i] = read_int(f);
}
break;
case F_FLOAT:
for (i = 0; i < field->size; i++) {
((float *)p)[i] = read_float(f);
}
break;
case F_VECTOR:
read_vector(f, (vec_t *)p);
break;
case F_LSTRING:
*(char **)p = read_string(f);
break;
case F_ZSTRING:
read_zstring(f, (char *)p, field->size);
break;
case F_EDICT:
*(edict_t **)p = read_index(f, sizeof(edict_t), g_edicts, game.maxentities - 1);
break;
case F_CLIENT:
*(gclient_t **)p = read_index(f, sizeof(gclient_t), game.clients, game.maxclients - 1);
break;
case F_ITEM:
*(gitem_t **)p = read_index(f, sizeof(gitem_t), itemlist, game.num_items - 1);
break;
case F_POINTER:
*(void **)p = read_pointer(f, field->size);
break;
default:
gi.error("%s: unknown field type", __func__);
}
}
开发者ID:Jenco420,项目名称:q2pro,代码行数:53,代码来源:g_save.c
注:本文中的read_float函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论