Use std::array instead of array

This commit is contained in:
Baptiste Wicht 2013-10-27 20:25:16 +01:00
parent df9475ba49
commit 5939b74098

View File

@ -1,4 +1,5 @@
#include <cstddef> #include <cstddef>
#include <array>
#include "types.hpp" #include "types.hpp"
#include "keyboard.hpp" #include "keyboard.hpp"
@ -66,8 +67,6 @@ bool str_equals(const char* a, const char* b){
return *a == *b; return *a == *b;
} }
#define COMMANDS 2
struct command_definition { struct command_definition {
const char* name; const char* name;
void (*function)(); void (*function)();
@ -76,10 +75,10 @@ struct command_definition {
void reboot_command(); void reboot_command();
void help_command(); void help_command();
command_definition commands[COMMANDS] = { std::array<command_definition, 2> commands = {{
{"reboot", reboot_command}, {"reboot", reboot_command},
{"help", help_command} {"help", help_command}
}; }};
void reboot_command(){ void reboot_command(){
interrupt<60>(); interrupt<60>();
@ -88,16 +87,16 @@ void reboot_command(){
void help_command(){ void help_command(){
k_print_line("Available commands:"); k_print_line("Available commands:");
for(int i = 0; i < COMMANDS; ++i){ for(auto& command : commands){
k_print(" "); k_print(" ");
k_print_line(commands[i].name); k_print_line(command.name);
} }
} }
void exec_command(){ void exec_command(){
for(int i = 0; i < COMMANDS; ++i){ for(auto& command : commands){
if(str_equals(current_input, commands[i].name)){ if(str_equals(current_input, command.name)){
commands[i].function(); command.function();
return; return;
} }