Myserial Library extends RawSerial

Files at this revision

API Documentation at this revision

Comitter:
naao
Date:
Mon Jun 23 07:45:15 2014 +0000
Parent:
5:72514f93cba9
Child:
7:d5fe75a0a885
Commit message:
change the overrides function to using template

Changed in this revision

MySerial.cpp Show annotated file Show diff for this revision Revisions of this file
MySerial.h Show annotated file Show diff for this revision Revisions of this file
--- a/MySerial.cpp	Sun Jun 22 09:48:41 2014 +0000
+++ b/MySerial.cpp	Mon Jun 23 07:45:15 2014 +0000
@@ -24,18 +24,3 @@
     }
     return 0;
 }
-
-int MySerial::GetString(char size, char (&cWord)[16])       //by ref : override function
-{
-    return GetString((int)size, &cWord[0]);
-}
-
-int MySerial::GetString(char size, char (&cWord)[256])      //by ref : override function
-{
-    return GetString((int)size, &cWord[0]);
-}
-
-int MySerial::GetString(char size, char (&cWord)[1024])     //by ref : override function
-{
-    return GetString((int)size, &cWord[0]);
-}
\ No newline at end of file
--- a/MySerial.h	Sun Jun 22 09:48:41 2014 +0000
+++ b/MySerial.h	Mon Jun 23 07:45:15 2014 +0000
@@ -27,7 +27,7 @@
  * void readbuf()
  * {
  *   // int iRtn =  pc.GetString(6,&cWord);    //Serial received chars by pointer cWord
- *    int iRtn =  pc.GetString((char)6,cWord); //Serial received chars byref of cWord
+ *    int iRtn =  pc.GetString(6,cWord); //Serial received chars byref of cWord
  * }
  * int main() {
  *    pc.attach( readbuf, MySerial::RxIrq );    //Set Interrupt by Serial receive
@@ -58,23 +58,10 @@
      * @param (&cWord)[16] returns got chars by ref
      * @param returns success by 0
      */
-    virtual int GetString(char size, char (&cWord)[16]);
-
-    /** override function to get chars after received shars by serial
-     * 
-     * @param int size for get chars
-     * @param (&cWord)[256] returns got chars by ref
-     * @param returns success by 0
-     */
-    virtual int GetString(char size, char (&cWord)[256]);
-
-    /** override function to get chars after received shars by serial
-     * 
-     * @param int size for get chars
-     * @param (&cWord)[1024] returns got chars by ref
-     * @param returns success by 0
-     */
-    virtual int GetString(char size, char (&cWord)[1024]);
+    template <class X> int GetString(int size, X cWord)
+    {
+        return GetString(size, &cWord[0]);
+    }
 
 protected: