Browse Source

Added FILE pointer support to Jupiter::DataBuffer

Minor fix in Jupiter::SLList
release/0.19
JustinAJ 10 years ago
parent
commit
1faf633100
  1. 40
      Jupiter/DataBuffer.cpp
  2. 3
      Jupiter/DataBuffer.h
  3. 1
      Jupiter/Jupiter.vcxproj
  4. 3
      Jupiter/Jupiter.vcxproj.filters
  5. 7
      Jupiter/SLList.h
  6. BIN
      Release/Jupiter.lib

40
Jupiter/DataBuffer.cpp

@ -26,6 +26,46 @@ Jupiter::DataBuffer::DataBuffer(size_t size_)
Jupiter::DataBuffer::bufferSize = size_;
}
Jupiter::DataBuffer::DataBuffer(FILE *file)
{
fread(std::addressof(Jupiter::DataBuffer::bufferSize), sizeof(size_t), 1, file);
Jupiter::DataBuffer::base = reinterpret_cast<uint8_t *>(malloc(Jupiter::DataBuffer::bufferSize * sizeof(uint8_t)));
Jupiter::DataBuffer::head = Jupiter::DataBuffer::base;
Jupiter::DataBuffer::end = Jupiter::DataBuffer::head + Jupiter::DataBuffer::bufferSize;
int chr;
while (Jupiter::DataBuffer::head != Jupiter::DataBuffer::end)
{
chr = fgetc(file);
if (chr == EOF)
{
Jupiter::DataBuffer::end = Jupiter::DataBuffer::head + 1;
break;
}
*Jupiter::DataBuffer::head++ = static_cast<uint8_t>(chr);
}
Jupiter::DataBuffer::head = Jupiter::DataBuffer::base;
}
Jupiter::DataBuffer::DataBuffer(FILE *file, size_t size_)
{
Jupiter::DataBuffer::bufferSize = size_;
Jupiter::DataBuffer::base = reinterpret_cast<uint8_t *>(malloc(Jupiter::DataBuffer::bufferSize * sizeof(uint8_t)));
Jupiter::DataBuffer::head = Jupiter::DataBuffer::base;
Jupiter::DataBuffer::end = Jupiter::DataBuffer::head + Jupiter::DataBuffer::bufferSize;
int chr;
while (Jupiter::DataBuffer::head != Jupiter::DataBuffer::end)
{
chr = fgetc(file);
if (chr == EOF)
{
Jupiter::DataBuffer::end = Jupiter::DataBuffer::head + 1;
break;
}
*Jupiter::DataBuffer::head++ = static_cast<uint8_t>(chr);
}
Jupiter::DataBuffer::head = Jupiter::DataBuffer::base;
}
Jupiter::DataBuffer::~DataBuffer()
{
free(Jupiter::DataBuffer::base);

3
Jupiter/DataBuffer.h

@ -24,6 +24,7 @@
*/
#include <cstdint>
#include <cstdio>
#include "Jupiter.h"
namespace Jupiter
@ -201,6 +202,8 @@ namespace Jupiter
DataBuffer();
DataBuffer(size_t size);
DataBuffer(FILE *file);
DataBuffer(FILE *file, size_t size);
~DataBuffer();
private:

1
Jupiter/Jupiter.vcxproj

@ -179,6 +179,7 @@
<ClCompile Include="Base64C.c" />
<ClCompile Include="Command.cpp" />
<ClCompile Include="Config.cpp" />
<ClCompile Include="Database.cpp" />
<ClCompile Include="DataBuffer.cpp" />
<ClCompile Include="File.cpp" />
<ClCompile Include="Functions.c" />

3
Jupiter/Jupiter.vcxproj.filters

@ -126,6 +126,9 @@
<ClCompile Include="DataBuffer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Database.cpp">
<Filter>Source Files\Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Functions.h">

7
Jupiter/SLList.h

@ -161,12 +161,7 @@ template<typename T> typename Jupiter::SLList<T>::Node *Jupiter::SLList<T>::getN
return t;
}
template<typename T> T *Jupiter::SLList<T>::get(size_t index)
{
return Jupiter::SLList<T>::getNode(index)->data;
}
template<typename T> const T *Jupiter::SLList<T>::get(size_t index) const
template<typename T> T *Jupiter::SLList<T>::get(size_t index) const
{
return Jupiter::SLList<T>::getNode(index)->data;
}

BIN
Release/Jupiter.lib

Binary file not shown.
Loading…
Cancel
Save