AP_HAL: Add Util member for string utilities

This commit is contained in:
Pat Hickey 2012-12-18 16:09:24 -08:00 committed by Andrew Tridgell
parent 372c0074b1
commit 0d702045b8
4 changed files with 34 additions and 2 deletions

View File

@ -17,6 +17,7 @@
#include "RCOutput.h"
#include "Scheduler.h"
#include "Semaphore.h"
#include "Util.h"
#include "utility/Print.h"
#include "utility/Stream.h"

View File

@ -26,6 +26,8 @@ namespace AP_HAL {
class RCOutput;
class Scheduler;
class Semaphore;
class Util;
/* Utility Classes */
class Print;

View File

@ -26,7 +26,8 @@ public:
AP_HAL::GPIO* _gpio,
AP_HAL::RCInput* _rcin,
AP_HAL::RCOutput* _rcout,
AP_HAL::Scheduler* _scheduler)
AP_HAL::Scheduler* _scheduler,
AP_HAL::Util* _util)
:
uartA(_uartA),
uartB(_uartB),
@ -39,7 +40,8 @@ public:
gpio(_gpio),
rcin(_rcin),
rcout(_rcout),
scheduler(_scheduler)
scheduler(_scheduler),
util(_util)
{}
virtual void init(int argc, char * const argv[]) const = 0;
@ -56,6 +58,7 @@ public:
AP_HAL::RCInput* rcin;
AP_HAL::RCOutput* rcout;
AP_HAL::Scheduler* scheduler;
AP_HAL::Util* util;
};
#endif // __AP_HAL_HAL_H__

26
libraries/AP_HAL/Util.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef __AP_HAL_UTIL_H__
#define __AP_HAL_UTIL_H__
#include <stdarg.h>
#include "AP_HAL_Namespace.h"
#include <AP_Progmem.h>
class AP_HAL::Util {
public:
virtual int snprintf(char* str, size_t size,
const char *format, ...) = 0;
virtual int snprintf_P(char* str, size_t size,
const prog_char_t *format, ...) = 0;
virtual int vsnprintf(char* str, size_t size,
const char *format, va_list ap) = 0;
virtual int vsnprintf_P(char* str, size_t size,
const prog_char_t *format, va_list ap) = 0;
};
#endif // __AP_HAL_UTIL_H__