当前位置: 首页>>代码示例>>C++>>正文


C++ dict_read_first函数代码示例

本文整理汇总了C++中dict_read_first函数的典型用法代码示例。如果您正苦于以下问题:C++ dict_read_first函数的具体用法?C++ dict_read_first怎么用?C++ dict_read_first使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dict_read_first函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: app_message_read_card_payload

static void app_message_read_card_payload(DictionaryIterator *dict, int32_t card_index) {
    Tuple *tuple = dict_read_first(dict);
    if (!tuple) {
        APP_LOG(APP_LOG_LEVEL_ERROR, "[CARD %ld] dict_read_first -> NULL", card_index);
        return;
    }

    while (tuple) {
        uint32_t cstr_key = 0;
        uint32_t data_key = 0;
        switch (tuple->key) {
            case KEY_CARD_BALANCE:
                cstr_key = STORAGE_CARD_VALUE(BALANCE, card_index);
                break;
            case KEY_CARD_BARCODE_DATA:
                data_key = STORAGE_CARD_VALUE(BARCODE_DATA, card_index);
                break;
            case KEY_CARD_NAME:
                cstr_key = STORAGE_CARD_VALUE(NAME, card_index);
                break;
        }

        if (cstr_key) {
            persist_write_string(cstr_key, tuple->value->cstring);
        } else if (data_key) {
            persist_write_data(data_key, tuple->value->data, tuple->length);
        }

        tuple = dict_read_next(dict);
    }
}
开发者ID:henriwatson,项目名称:PebbleBucks,代码行数:31,代码来源:main.c

示例2: Process_Received_Data

static void Process_Received_Data(DictionaryIterator *iter, void *context){
	Tuple *t = dict_read_first(iter);
	 while(t != NULL){
		APP_LOG(APP_LOG_LEVEL_INFO, "something received");
		int key = t->key;
        int value = t->value->int32;
		char string_value[32];
		strcpy(string_value, t->value->cstring);	
		switch (key){
			case WEATHER_TEMPERATURE:
				APP_LOG(APP_LOG_LEVEL_INFO, string_value);
				snprintf(Weather_Buffer, sizeof(Weather_Buffer), "%s", string_value);
				text_layer_set_text(Weather_Text, Weather_Buffer);
				break;
			
			case WEATHER_CONDITIONS:
				gbitmap_destroy(Weather_Bitmap); 
				Weather_Bitmap = gbitmap_create_with_resource(Weather_icons[value]); 
				bitmap_layer_set_bitmap(Weather_Layer, Weather_Bitmap); 
				break;
			
			case SETTINGS_HOURLY_VIBE:
				Settings.Vibe_Hourly = value;
				break;
			
			case SETTINGS_BT_VIBE:
				Settings.Vibe_BT = value;
		}
		 
		 
        t = dict_read_next(iter);
    }	
}
开发者ID:GrakovNe,项目名称:Pebble-vic4884,代码行数:33,代码来源:main.c

示例3: inbox_received_handler

static void inbox_received_handler(DictionaryIterator *iterator, void *context) {
  // Get the first pair
  Tuple *t = dict_read_first(iterator);

  int key = (int)(t->key / 256);
  int menu_item_section = (int)((t->key % 256) / 16);
  int menu_item = (t->key % 16);
  // Process all pairs present
  while(t != NULL) {
    // Process this pair's key
    switch(key) {
      case KEY_STATUS:
      APP_LOG(APP_LOG_LEVEL_INFO, "STATUS for KEY %d is %d", key, (int)t->value->int32);
        menu_item_statuses[menu_item_section][menu_item] = get_status_text((int)t->value->int32);
        menu_layer_reload_data(s_menu_layer);
        break;
      case KEY_VIBRATE:
        // Trigger vibration
//         text_layer_set_text(s_text_layer, "Vibrate!");
        APP_LOG(APP_LOG_LEVEL_INFO, "Vibrate!");
        vibes_short_pulse();
        break;
      default:
        APP_LOG(APP_LOG_LEVEL_INFO, "Unknown key: %d", (int)t->key);
        break;
    }

    // Get next pair, if any
    t = dict_read_next(iterator);
  }
}
开发者ID:kvv20,项目名称:SwissArmyPebble,代码行数:31,代码来源:main.c

示例4: inbox_received_callback

static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
	
  // Read first item
  Tuple *t = dict_read_first(iterator);

  text_layer_set_text( title_layer, title );
	
  // For all items
  while(t != NULL) {
    // Which key was received?
		APP_LOG(APP_LOG_LEVEL_DEBUG, "Loop index now %s", t->value->cstring);
    switch(t->key) {
    case KEY_ABSTRACT:
          snprintf(abstract, sizeof(abstract), "%s", t->value->cstring);			
      break;
    case KEY_TITLE:
          snprintf(title, sizeof(title), "%s", t->value->cstring);
      break;
    default:
      snprintf( title, sizeof(abstract), "%s", t->value->cstring );
      break;
    }
		text_layer_set_text( word_layer, abstract );// Look for next item
    app_timer_register( (200+10*( strlen(abstract) )), (AppTimerCallback) refresh, NULL);
    
		psleep(500);
    t = dict_read_next(iterator);
  }
  window_stack_pop(true);  
}
开发者ID:kyleliangus,项目名称:KeySpeedRead,代码行数:30,代码来源:main.c

示例5: in_recv_handler

static void in_recv_handler(DictionaryIterator *iterator, void *context)
{
  //Get Tuple
  Tuple *t = dict_read_first(iterator);
  while (t)
  {
    switch(t->key) {
    case KEY_INVERT:
      //It's the KEY_INVERT key
      inverted = (strcmp(t->value->cstring, "si") == 0);
      layer_set_hidden((Layer *)ILFondo, inverted);
 	  persist_write_bool(KEY_INVERT, inverted);
      break;
	  
	case KEY_IDIOMA:
      //It's the KEY_INVERT key
      if(strcmp(t->value->cstring, "1")==0)
      {
        //Set and save as inverted
		idioma=1;  
        persist_write_int(KEY_IDIOMA, 1);
      }
      else if(strcmp(t->value->cstring, "0")==0)
      {
        //Set and save as not inverted
		idioma = 0;
        persist_write_int(KEY_IDIOMA, 0);
      }
      break;
    }
	t = dict_read_next(iterator);
  }
}
开发者ID:manelto,项目名称:pizarra,代码行数:33,代码来源:main.c

示例6: in_received_handler

void in_received_handler(DictionaryIterator *iter, void *context) {
    /* get data */
    Tuple *t = dict_read_first(iter);
    while (t) {
        int key = t->key;
        
        char tmp[BUFSIZE] = "";
        strncpy(tmp, t->value->cstring, BUFSIZE);
        
        switch (key) {
            case STR_CHANGE_UP:
                strncpy(str_drink_up, tmp, BUFSIZE);
                text_layer_set_text(text_layer_top, str_drink_up);
                break;
            case STR_CHANGE_SELECT:
                strncpy(str_drink_select, tmp, BUFSIZE);
                text_layer_set_text(text_layer_center, str_drink_select);
                break;
            case STR_CHANGE_DOWN:
                strncpy(str_drink_down, tmp, BUFSIZE);
                text_layer_set_text(text_layer_bottom, str_drink_down);
                break;
        }
        
        /* get even more data */
        t = dict_read_next(iter);
    }
}
开发者ID:nilsding,项目名称:twoffein-pebble,代码行数:28,代码来源:twoffein_pebble.c

示例7: inbox_received_callback

static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
    // Read first item
  Tuple *t = dict_read_first(iterator);
  
  // For all items
  while(t != NULL) {
    // Which key was received?
    switch(t->key) {
    case KEY_LONGITUDE:
      currentlong = TRIG_MAX_ANGLE / 4 + TRIG_MAX_ANGLE * t->value->int32 / 360;
      break;
    case KEY_LATITUDE:
      currentlat = TRIG_MAX_ANGLE / 2 - (TRIG_MAX_ANGLE / 4 - TRIG_MAX_ANGLE  * t->value->int32 / 360);
      break;
    case KEY_TIMEZONE:
      timezone_offset = t->value->int32;
      APP_LOG(APP_LOG_LEVEL_ERROR, "Timezone offset received %d", (int)timezone_offset);
      break;
    default:
      APP_LOG(APP_LOG_LEVEL_ERROR, "Key %d not recognized!", (int)t->key);
      break;
    }

    // Look for next item
    t = dict_read_next(iterator);
  }
}
开发者ID:mwarrenus,项目名称:PebbleGlobe,代码行数:27,代码来源:message.c

示例8: inbox_received_callback

static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  // Store incoming information
  static char speed_buffer[8];
  
  // Read first item
  Tuple *t = dict_read_first(iterator);

  // For all items
  while(t != NULL) {
    // Which key was received?
    switch(t->key) {
    case KEY_SPEED:
      snprintf(speed_buffer, sizeof(speed_buffer), "%d", (int)t->value->int32);
      APP_LOG(APP_LOG_LEVEL_INFO, "Speed parsed");
      break;
    default:
      APP_LOG(APP_LOG_LEVEL_ERROR, "Key %d not recognized!", (int)t->key);
      break;
    }

    // Look for next item
    t = dict_read_next(iterator);
  }
  
  APP_LOG(APP_LOG_LEVEL_DEBUG, "%s", speed_buffer);
  //text_layer_set_text(speed_layer, speed_buffer);
  //Window *curWindow = window_stack_get_top_window();
  //TextLayer *speedLayer = text_layer_get_layer(speed_layer);
  
}
开发者ID:housser,项目名称:Pebble-Yacht-Racing,代码行数:30,代码来源:yacht_racing.c

示例9: handle_appmessage_receive

void handle_appmessage_receive(DictionaryIterator *received, void *context) {
  Tuple *tuple = dict_read_first(received);
  while (tuple) {
    switch (tuple->key) {
      case SECONDS_MODE:
        seconds_mode = tuple->value->int32;
        break;
      case BATTERY_MODE:
        battery_mode = tuple->value->int32;
        break;
      case DATE_MODE:
        date_mode = tuple->value->int32;
        break;
      case BLUETOOTH_MODE:
        bluetooth_mode = tuple->value->int32;
        break;
      case GRAPHICS_MODE:
        graphics_mode = tuple->value->int32;
        break;
      case CONNLOST_MODE:
        connlost_mode = tuple->value->int32;
        break;
    }
    tuple = dict_read_next(received);
  }
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Received config");
  has_config = true;
  handle_battery(battery_state_service_peek());
  handle_bluetooth(bluetooth_connection_service_peek());
  handle_inverter();
}
开发者ID:agreen,项目名称:PebbleONE,代码行数:31,代码来源:pebble_one.c

示例10: inbox_received_callback

static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  APP_LOG(APP_LOG_LEVEL_INFO, "Message received!");
  Tuple *t = dict_read_first(iterator);

  // Process all pairs present
  while(t != NULL) {
    // Process this pair's key
    switch (t->key) {
      case KEY_PHONE:
        persist_write_string(PERSIST_KEY_PHONE_NUMBER, t->value->cstring);
        break;
      case KEY_NAME:
        persist_write_string(PERSIST_KEY_NAME, t->value->cstring);
        break;
      case KEY_TIMER:
        persist_write_int(PERSIST_KEY_INTERVAL_TIME, t->value->int32);
        break;
      case KEY_VIBRATE:
        persist_write_int(PERSIST_KEY_BUZZ_TIME, t->value->int32);
        break;
    }

    // Get next pair, if any
    t = dict_read_next(iterator);
  }
}
开发者ID:Herschee,项目名称:Watchdog,代码行数:26,代码来源:clock.c

示例11: inbox_received_callback

static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  // Get the first pair
  Tuple *t = dict_read_first(iterator);

  // Process all pairs present
  while (t != NULL) {
    // Long lived buffer
//     static char s_buffer[64];

    // Process this pair's key
    switch (t->key) {
      case 1:
        // Copy value and display8
//         snprintf(s_buffer, sizeof(s_buffer), "Received '%s'", t->value->cstring);
      circle_layer1 = layer_create(GRect(0, 0, 144, 50));
      
//         text_layer_set_text(s_output_layer, s_buffer);
          layer_set_update_proc(circle_layer1, draw_circle1_update_proc);
           layer_add_child(window_layer, circle_layer1);
        break;
      case 2:
      circle_layer2 = layer_create(GRect(0, 0, 144, 50));
          layer_set_update_proc(circle_layer2, draw_circle2_update_proc); 
          layer_add_child(window_layer, circle_layer2);
      break;
    }

    // Get next pair, if any
    t = dict_read_next(iterator);
  }
}
开发者ID:ttingt,项目名称:Supported,代码行数:31,代码来源:hello_world.c

示例12: inbox_received_callback

static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  Tuple *t = dict_read_first(iterator);
  
  while(t != NULL) {
    switch (t->key) {
      case NUM_MENU_ITEMS:
        s_num_menu_items = t->value->uint16;
        break;
      case POSTS:
      {
        ProcessingState *state = data_processor_create(t->value->cstring, '|');
        uint8_t num_strings = data_processor_count(state);
        s_strings = malloc(sizeof(char*) * num_strings);
        for (uint8_t n = 0; n < num_strings; n += 1) {
          s_strings[n] = data_processor_get_string(state);
        }
        data_processor_destroy(state);
        break;
      }
      case COMMENTS:
        break;
    }
    // Get next pair, if any
    t = dict_read_next(iterator);
  }
  
  layer_mark_dirty(menu_layer_get_layer(s_menu_layer));
}
开发者ID:haydentherapper,项目名称:GameDealsApp,代码行数:28,代码来源:main.c

示例13: inbox_received_callback

static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  static char temperture_buffer[8];
  static char conditions_buffer[32];
  static char weather_layer_buffer[32];
  // First item
  Tuple *t = dict_read_first(iterator);
  
  // Is the latest key NULL after latest iteration?
  while (t != NULL) {
    switch (t->key) {
      case KEY_TEMPERATURE:
      // write outputted format to sized buffer
      snprintf(temperture_buffer, sizeof(temperture_buffer), "%dF", (int)t->value->int32);
      break;
      
      case KEY_CONDITIONS:
      snprintf(conditions_buffer, sizeof(conditions_buffer), "%s", t->value->cstring);
      break;
      
      default:
      APP_LOG(APP_LOG_LEVEL_ERROR, "Unexpected key:%d", (int)t->key);
    }
    
    // Move onto to the next key
    t = dict_read_next(iterator);
  }
  snprintf(weather_layer_buffer, sizeof(weather_layer_buffer), "%s %s", temperture_buffer, conditions_buffer);
  text_layer_set_text(s_weather_layer, weather_layer_buffer);
}
开发者ID:Marrrrrrk,项目名称:PebbleWatchface,代码行数:29,代码来源:main.c

示例14: in_recv_handler

static void in_recv_handler(DictionaryIterator *iterator, void *context)
{
  //Get Tuple
  Tuple *t = dict_read_first(iterator);
  if(t)
  {
    switch(t->key)
    {
    case KEY_SPEED:
      //It's the KEY_INVERT key
      if(strcmp(t->value->cstring, "on") == 0)
      {
        //Set and save as inverted
        text_layer_set_text_color(text_layer, GColorWhite);
        text_layer_set_background_color(text_layer, GColorBlack);
        text_layer_set_text(text_layer, "Inverted!");
 
        persist_write_bool( KEY_SPEED, true);
      }
      else if(strcmp(t->value->cstring, "off") == 0)
      {
        //Set and save as not inverted
        text_layer_set_text_color(text_layer, GColorBlack);
        text_layer_set_background_color(text_layer, GColorWhite);
        text_layer_set_text(text_layer, "Not inverted!");
 
        persist_write_bool( KEY_SPEED, false);
      }
      break;
    }
  }
}
开发者ID:BOBdotEXE,项目名称:MegmanBasic,代码行数:32,代码来源:main.c

示例15: in_received_handler

static void in_received_handler(DictionaryIterator *iter, void *context) {
  Tuple *tuple = dict_read_first(iter);
  while (tuple) {   
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Pebble received message with key %u", (unsigned)tuple->key);
    switch (tuple->key) {
      case 3:
        APP_LOG(APP_LOG_LEVEL_DEBUG, "Pebble received message requesting value update");
        sendDefaultsToJS();
        return; // don't save values on request  
      case 0:
        APP_LOG(APP_LOG_LEVEL_DEBUG, "Pebble received message with new background value");
        backgroundBlack = tuple->value->int8;
        break;
      case 1:
        APP_LOG(APP_LOG_LEVEL_DEBUG, "Pebble received message with new show day value");
        showDay = tuple->value->int8;
        break;
    }
    tuple = dict_read_next(iter);
  }
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Pebble received message: background=%d, showDay=%d", backgroundBlack, showDay);
  
  // If not MSG_KEY_REQ_VALUES, then really expect both other keys to be present
  setupBackground();
  drawCurrentTime();
  savePersistentValues();
}                
开发者ID:hhundsch,项目名称:big_time_date,代码行数:27,代码来源:big_time_date.c


注:本文中的dict_read_first函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。