Skip to content

intelhex::endOfData should return false at the last byte of the hex file #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion intelhex_class/intelhexclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,9 @@ istream& operator>>(istream& dataIn, intelhex& ihLocal)
if (ihLocal.verbose == true)
{
cout << "Data Record begining @ 0x" <<
ihLocal.ulToHexString(loadOffset) << endl;
ihLocal.ulToHexString(loadOffset) <<
" size 0x" <<
ihLocal.ulToHexString(recordLength) << endl;
}
break;

Expand Down
52 changes: 22 additions & 30 deletions intelhex_class/intelhexclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
* DEFINES
*******************************************************************************/

using namespace std;
//using namespace std;

/******************************************************************************/
/*! \cond
Expand Down Expand Up @@ -90,7 +90,7 @@ class intelhex {
*
* \retval - pointer to output stream
***********************************************************************/
friend ostream& operator<<(ostream& dataOut,
friend std::ostream& operator<<(std::ostream& dataOut,
intelhex& ihLocal);

/**********************************************************************/
Expand All @@ -107,7 +107,7 @@ class intelhex {
*
* \retval - pointer to input stream
***********************************************************************/
friend istream& operator>>(istream& dataIn,
friend std::istream& operator>>(std::istream& dataIn,
intelhex& ihLocal);

private:
Expand All @@ -117,7 +117,7 @@ class intelhex {
* STL map holding the addresses found in the Intel HEX file and the
* associated data byte stored at that address
***********************************************************************/
map<unsigned long, unsigned char> ihContent;
std::map<unsigned long, unsigned char> ihContent;

/**********************************************************************/
/*! \brief Iterator for the container holding the decoded Intel HEX
Expand All @@ -127,7 +127,7 @@ class intelhex {
* currently being used to read or write data. If no file has been
* loaded into memory, it points to the start of ihContent.
***********************************************************************/
map<unsigned long, unsigned char>::iterator ihIterator;
std::map<unsigned long, unsigned char>::iterator ihIterator;

/**********************************************************************/
/*! \brief Pair for the container holding the decoded Intel HEX content.
Expand All @@ -138,7 +138,7 @@ class intelhex {
* can ensure that no address in a file is falsely assigned data more
* than once.
***********************************************************************/
pair<map<unsigned long, unsigned char>::iterator,bool> ihReturn;
std::pair<std::map<unsigned long, unsigned char>::iterator,bool> ihReturn;

/**********************************************************************/
/*! \brief Stores segment base address of Intel HEX file.
Expand Down Expand Up @@ -208,7 +208,7 @@ class intelhex {
* the list
***********************************************************************/
struct {
list<string> ihWarnings;
std::list<std::string> ihWarnings;
unsigned long noOfWarnings;
} msgWarning;

Expand All @@ -223,7 +223,7 @@ class intelhex {
* list
***********************************************************************/
struct {
list<string> ihErrors;
std::list<std::string> ihErrors;
unsigned long noOfErrors;
} msgError;

Expand Down Expand Up @@ -273,7 +273,7 @@ class intelhex {
*
* \sa ulToHexString(), ucToHexString(), ulToString()
***********************************************************************/
unsigned char stringToHex(string value);
unsigned char stringToHex(std::string value);

/***********************************************************************
* \brief Converts an unsigned long to a string in HEX format.
Expand All @@ -292,7 +292,7 @@ class intelhex {
* \sa
* stringToHex(), ucToHexString(), ulToString()
***********************************************************************/
string ulToHexString(unsigned long value);
std::string ulToHexString(unsigned long value);

/**********************************************************************/
/*! \brief Converts an unsigned char to a string in HEX format.
Expand All @@ -311,7 +311,7 @@ class intelhex {
* \sa
* stringToHex(), ulToHexString(), ulToString()
***********************************************************************/
string ucToHexString(unsigned char value);
std::string ucToHexString(unsigned char value);

/**********************************************************************/
/*! \brief Converts an unsigned long to a string in DEC format.
Expand All @@ -327,7 +327,7 @@ class intelhex {
* \sa
* stringToHex(), ulToHexString(), ucToHexString()
***********************************************************************/
string ulToString(unsigned long value);
std::string ulToString(unsigned long value);

/**********************************************************************/
/*! \brief Decodes the data content of a data record.
Expand All @@ -346,22 +346,22 @@ class intelhex {
***********************************************************************/
void decodeDataRecord(unsigned char recordLength,
unsigned long loadOffset,
string::const_iterator data);
std::string::const_iterator data);

/**********************************************************************/
/*! \brief Add a warning message to the warning message list.
*
*
* \param warningMessage - the text to be added for this warning
***********************************************************************/
void addWarning(string warningMessage);
void addWarning(std::string warningMessage);

/**********************************************************************/
/*! \brief Add an error message to the error message list.
*
* \param errorMessage - the text to be added for this error
***********************************************************************/
void addError(string errorMessage);
void addError(std::string errorMessage);

public:
/**********************************************************************/
Expand Down Expand Up @@ -615,15 +615,7 @@ class intelhex {

if (!ihContent.empty())
{
map<unsigned long, unsigned char>::iterator it \
= ihContent.end();

--it;

if (it != ihIterator)
{
result = false;
}
return ihIterator == ihContent.end();
}
return result;
}
Expand Down Expand Up @@ -661,7 +653,7 @@ class intelhex {

if (ihContent.size() != 0)
{
map<unsigned long, unsigned char>::iterator it;
std::map<unsigned long, unsigned char>::iterator it;
it = ihContent.find(address);
if (it != ihContent.end())
{
Expand Down Expand Up @@ -774,7 +766,7 @@ class intelhex {
{
if (ihContent.size() != 0)
{
map<unsigned long, unsigned char>::iterator it;
std::map<unsigned long, unsigned char>::iterator it;

it = ihContent.begin();
*address = (*it).first;
Expand Down Expand Up @@ -802,7 +794,7 @@ class intelhex {
{
if (ihContent.size() != 0)
{
map<unsigned long, unsigned char>::reverse_iterator rit;
std::map<unsigned long, unsigned char>::reverse_iterator rit;

rit = ihContent.rbegin();
*address = (*rit).first;
Expand Down Expand Up @@ -858,7 +850,7 @@ class intelhex {
bool getData(unsigned char * data, unsigned long address)
{
bool found = false;
map<unsigned long, unsigned char>::iterator localIterator;
std::map<unsigned long, unsigned char>::iterator localIterator;

if (!ihContent.empty())
{
Expand Down Expand Up @@ -979,7 +971,7 @@ class intelhex {
*
* \sa getNoWarnings(), getNoErrors(), popNextError()
***********************************************************************/
bool popNextWarning(string& warning)
bool popNextWarning(std::string& warning)
{
if (msgWarning.noOfWarnings > 0)
{
Expand Down Expand Up @@ -1010,7 +1002,7 @@ class intelhex {
*
* \sa getNoWarnings(), getNoErrors(), popNextError()
***********************************************************************/
bool popNextError(string& error)
bool popNextError(std::string& error)
{
if (msgError.noOfErrors > 0)
{
Expand Down