Skip to content

Commit

Permalink
consistent indentation with astyle (before releasing 8.3.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnLangford committed Dec 29, 2016
1 parent d078d3d commit da66064
Show file tree
Hide file tree
Showing 220 changed files with 29,331 additions and 30,230 deletions.
130 changes: 60 additions & 70 deletions cs/cli/clr_io.cpp
Expand Up @@ -12,74 +12,64 @@ using namespace System::Runtime::InteropServices;

namespace VW
{
clr_io_buf::clr_io_buf(Stream^ stream) : m_stream(stream), m_buffer(nullptr)
{
if (stream == nullptr)
throw gcnew ArgumentNullException("stream");

files.push_back(0);
}

void clr_io_buf::ensure_buffer_size(size_t nbytes)
{
if (m_buffer != nullptr && m_buffer->Length >= nbytes)
return;

m_buffer = gcnew array<unsigned char>((int)nbytes);
}

int clr_io_buf::open_file(const char* name, bool stdin_off, int flag)
{
return 0;
}

void clr_io_buf::reset_file(int f)
{
m_stream->Seek(0, SeekOrigin::Begin);
head = space.begin();

space.end() = space.begin();
}

ssize_t clr_io_buf::read_file(int f, void* buf, size_t nbytes)
{
ensure_buffer_size(nbytes);

int readBytes = m_stream->Read(m_buffer, 0, (int)nbytes);
Marshal::Copy(m_buffer, 0, IntPtr(buf), (int)nbytes);

return readBytes;
}

size_t clr_io_buf::num_files()
{
return 1;
}

ssize_t clr_io_buf::write_file(int file, const void* buf, size_t nbytes)
{
ensure_buffer_size(nbytes);

Marshal::Copy(IntPtr((void*)buf), m_buffer, 0, (int)nbytes);
m_stream->Write(m_buffer, 0, (int)nbytes);

return nbytes;
}

bool clr_io_buf::compressed()
{
return false;
}

void clr_io_buf::flush()
{
io_buf::flush();
m_stream->Flush();
}

bool clr_io_buf::close_file()
{
// don't close stream on purpose. Caller of SaveModel should have control when to close.
return true;
}
clr_io_buf::clr_io_buf(Stream^ stream) : m_stream(stream), m_buffer(nullptr)
{ if (stream == nullptr)
throw gcnew ArgumentNullException("stream");

files.push_back(0);
}

void clr_io_buf::ensure_buffer_size(size_t nbytes)
{ if (m_buffer != nullptr && m_buffer->Length >= nbytes)
return;

m_buffer = gcnew array<unsigned char>((int)nbytes);
}

int clr_io_buf::open_file(const char* name, bool stdin_off, int flag)
{ return 0;
}

void clr_io_buf::reset_file(int f)
{ m_stream->Seek(0, SeekOrigin::Begin);
head = space.begin();

space.end() = space.begin();
}

ssize_t clr_io_buf::read_file(int f, void* buf, size_t nbytes)
{ ensure_buffer_size(nbytes);

int readBytes = m_stream->Read(m_buffer, 0, (int)nbytes);
Marshal::Copy(m_buffer, 0, IntPtr(buf), (int)nbytes);

return readBytes;
}

size_t clr_io_buf::num_files()
{ return 1;
}

ssize_t clr_io_buf::write_file(int file, const void* buf, size_t nbytes)
{ ensure_buffer_size(nbytes);

Marshal::Copy(IntPtr((void*)buf), m_buffer, 0, (int)nbytes);
m_stream->Write(m_buffer, 0, (int)nbytes);

return nbytes;
}

bool clr_io_buf::compressed()
{ return false;
}

void clr_io_buf::flush()
{ io_buf::flush();
m_stream->Flush();
}

bool clr_io_buf::close_file()
{ // don't close stream on purpose. Caller of SaveModel should have control when to close.
return true;
}
}
46 changes: 23 additions & 23 deletions cs/cli/clr_io.h
Expand Up @@ -11,37 +11,37 @@ using namespace System::IO;

namespace VW
{
/// <summary>
/// C++ wrapper for managed <see cref="Stream"/>.
/// </summary>
class clr_io_buf : public io_buf
{
private:
gcroot<Stream^> m_stream;
gcroot<cli::array<unsigned char>^> m_buffer;
/// <summary>
/// C++ wrapper for managed <see cref="Stream"/>.
/// </summary>
class clr_io_buf : public io_buf
{
private:
gcroot<Stream^> m_stream;
gcroot<cli::array<unsigned char>^> m_buffer;

void ensure_buffer_size(size_t nbytes);
void ensure_buffer_size(size_t nbytes);

public:
/// <summary>
/// Initializes a new <see cref="clr_io_buf"/> instance.
/// </summary>
clr_io_buf(Stream^ stream);
public:
/// <summary>
/// Initializes a new <see cref="clr_io_buf"/> instance.
/// </summary>
clr_io_buf(Stream^ stream);

virtual int open_file(const char* name, bool stdin_off, int flag = READ);
virtual int open_file(const char* name, bool stdin_off, int flag = READ);

virtual void reset_file(int f);
virtual void reset_file(int f);

virtual ssize_t read_file(int f, void* buf, size_t nbytes);
virtual ssize_t read_file(int f, void* buf, size_t nbytes);

virtual size_t num_files();
virtual size_t num_files();

virtual ssize_t write_file(int file, const void* buf, size_t nbytes);
virtual ssize_t write_file(int file, const void* buf, size_t nbytes);

virtual bool compressed();
virtual bool compressed();

virtual void flush();
virtual void flush();

virtual bool close_file();
};
virtual bool close_file();
};
}
96 changes: 44 additions & 52 deletions cs/cli/clr_io_memory.cpp
Expand Up @@ -8,56 +8,48 @@ license as described in the file LICENSE.

namespace VW
{
clr_io_memory_buf::clr_io_memory_buf()
{
files.push_back(0);
m_iterator = m_data.begin();
}

int clr_io_memory_buf::open_file(const char* name, bool stdin_off, int flag)
{
m_iterator = m_data.begin();
return 0;
}

void clr_io_memory_buf::reset_file(int f)
{
size_t count = m_data.size();
m_iterator = m_data.begin();
}

ssize_t clr_io_memory_buf::read_file(int f, void* buf, size_t nbytes)
{
size_t left_over = min(nbytes, m_data.end() - m_iterator);

if (left_over == 0)
return 0;

memcpy_s(buf, nbytes, &*m_iterator, left_over);

m_iterator += left_over;

return left_over;
}

size_t clr_io_memory_buf::num_files()
{
return 1;
}

ssize_t clr_io_memory_buf::write_file(int file, const void* buf, size_t nbytes)
{
m_data.insert(m_data.end(), (char*)buf, (char*)buf + nbytes);
return nbytes;
}

bool clr_io_memory_buf::compressed()
{
return false;
}

bool clr_io_memory_buf::close_file()
{
return true;
}
clr_io_memory_buf::clr_io_memory_buf()
{ files.push_back(0);
m_iterator = m_data.begin();
}

int clr_io_memory_buf::open_file(const char* name, bool stdin_off, int flag)
{ m_iterator = m_data.begin();
return 0;
}

void clr_io_memory_buf::reset_file(int f)
{ size_t count = m_data.size();
m_iterator = m_data.begin();
}

ssize_t clr_io_memory_buf::read_file(int f, void* buf, size_t nbytes)
{ size_t left_over = min(nbytes, m_data.end() - m_iterator);

if (left_over == 0)
return 0;

memcpy_s(buf, nbytes, &*m_iterator, left_over);

m_iterator += left_over;

return left_over;
}

size_t clr_io_memory_buf::num_files()
{ return 1;
}

ssize_t clr_io_memory_buf::write_file(int file, const void* buf, size_t nbytes)
{ m_data.insert(m_data.end(), (char*)buf, (char*)buf + nbytes);
return nbytes;
}

bool clr_io_memory_buf::compressed()
{ return false;
}

bool clr_io_memory_buf::close_file()
{ return true;
}
}
42 changes: 21 additions & 21 deletions cs/cli/clr_io_memory.h
Expand Up @@ -10,34 +10,34 @@ license as described in the file LICENSE.

namespace VW
{
/// <summary>
/// IO Buffer keeping data in memory. Used by VowpalWabbit::Reload.
/// </summary>
class clr_io_memory_buf : public io_buf
{
private:
std::vector<char> m_data;
/// <summary>
/// IO Buffer keeping data in memory. Used by VowpalWabbit::Reload.
/// </summary>
class clr_io_memory_buf : public io_buf
{
private:
std::vector<char> m_data;

std::vector<char>::const_iterator m_iterator;
std::vector<char>::const_iterator m_iterator;

public:
/// <summary>
/// Initializes a new <see cref="clr_io_memory_buf"/> instance.
/// </summary>
clr_io_memory_buf();
public:
/// <summary>
/// Initializes a new <see cref="clr_io_memory_buf"/> instance.
/// </summary>
clr_io_memory_buf();

virtual int open_file(const char* name, bool stdin_off, int flag = READ);
virtual int open_file(const char* name, bool stdin_off, int flag = READ);

virtual void reset_file(int f);
virtual void reset_file(int f);

virtual ssize_t read_file(int f, void* buf, size_t nbytes);
virtual ssize_t read_file(int f, void* buf, size_t nbytes);

virtual size_t num_files();
virtual size_t num_files();

virtual ssize_t write_file(int file, const void* buf, size_t nbytes);
virtual ssize_t write_file(int file, const void* buf, size_t nbytes);

virtual bool compressed();
virtual bool compressed();

virtual bool close_file();
};
virtual bool close_file();
};
}
2 changes: 1 addition & 1 deletion cs/cli/resource.h
Expand Up @@ -3,7 +3,7 @@
// Used by Resource.rc

// Next default values for new objects
//
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
Expand Down

0 comments on commit da66064

Please sign in to comment.