-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working on internal moving and copyign utils
- Loading branch information
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef DATA_UTIL_H | ||
#define DATA_UTIL_H | ||
|
||
#include <string.h> | ||
#include "WindType.h" | ||
|
||
// This header handles utils to copy, move, and transport data from one unsigned char* | ||
// to another | ||
|
||
// Copies data from src to dest, until src End is reached. | ||
int DataUtil_copy(unsigned char* dest, | ||
const unsigned char* src, | ||
const unsigned char* srcEnd); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "DataUtil.h" | ||
|
||
int DataUtil_copy(unsigned char* dest, const unsigned char* src, const unsigned char* srcEnd) | ||
{ | ||
while(src != srcEnd) | ||
{ | ||
switch(*src) | ||
{ | ||
case WindType_Not: | ||
case WindType_Sep: | ||
case WindType_Assign: | ||
case WindType_None: | ||
case WindType_Del: | ||
case WindType_Lt: | ||
case WindType_Gt: | ||
case WindType_Plus: | ||
case WindType_Minus: | ||
case WindType_Multiply: | ||
case WindType_Divide: | ||
*dest++ = *src++; | ||
break; | ||
case WindType_Bool: | ||
*dest++ = *src++; | ||
*dest++ = *src++; | ||
break; | ||
case WindType_Number: | ||
WindComp_BUF[0] = *item++; | ||
for(size_t ds = 1; ds < sizeof(double) + 1; ds++) | ||
WindComp_BUF[ds] = *item++; | ||
WindComp_ITEM_LEN = sizeof(unsigned char) + sizeof(double); | ||
return WindComp_ITEM_LEN; | ||
case WindType_String: | ||
WindComp_BUF[0] = *item++; | ||
WindComp_ITEM_LEN = *(unsigned*)(item) + sizeof(unsigned) + sizeof(unsigned char); | ||
memcpy(WindComp_BODY, (unsigned char*)item, WindComp_ITEM_LEN); | ||
return WindComp_ITEM_LEN; | ||
default: | ||
return 0; | ||
} | ||
} | ||
return 1; | ||
} |