Logo Search packages:      
Sourcecode: ocropus version File versions  Download package

narray-io.h File Reference

Detailed Description

I/O utilities for narrays.

Definition in file narray-io.h.

#include <stdio.h>
#include <stdlib.h>
#include "colib.h"

Go to the source code of this file.


namespace  ocropus


void ocropus::bin_append (colib::bytearray &a, const char *path)
void ocropus::bin_append (const char *path, colib::bytearray &a)
void ocropus::bin_append (colib::bytearray &a, FILE *f)
void ocropus::bin_append (FILE *f, bytearray &a)
void ocropus::bin_read (colib::bytearray &a, const char *path)
void ocropus::bin_read (const char *path, colib::bytearray &a)
void ocropus::bin_read (colib::bytearray &a, FILE *f)
void ocropus::bin_read (FILE *f, bytearray &a)
void ocropus::bin_read_1d (FILE *f, intarray &a)
void ocropus::bin_read_mnist_dims (FILE *f, intarray &a)
void ocropus::bin_read_nustring (FILE *f, nustring &a)
void ocropus::bin_write (colib::bytearray &a, const char *path)
void ocropus::bin_write (const char *path, colib::bytearray &a)
void ocropus::bin_write (colib::bytearray &a, FILE *f)
void ocropus::bin_write (FILE *f, bytearray &a)
void ocropus::bin_write_1d (FILE *f, intarray &a)
void ocropus::bin_write_mnist_dims (FILE *f, intarray &a)
void ocropus::bin_write_nustring (FILE *f, nustring &a)
void ocropus::parse_vector (colib::doublearray &, const char *)
 Create a 1D doublearray given a string with space-separated numbers.
void ocropus::print (colib::doublearray &a)
 Print a 1D or 2D doublearray to stdout.
template<class T>
void ocropus::printf_matrix (const char *format, colib::narray< T > &a)
 Print a 2D array formatted with to the given format string.
template<class T>
void ocropus::printf_narray (const char *format, colib::narray< T > &a)
 Print any 1D or 2D array formatted with the given format string.
template<class T>
void ocropus::printf_vector (const char *format, colib::narray< T > &a)
 Print any array as 1D vector formatted with the given format string.
void ocropus::read_checkpoint (FILE *f, const char *)
 Read a `checkpoint'. The given identifier should exactly match the one in the file.
int32_t ocropus::read_int32 (FILE *f)
 Read a 32-bit integer from the file in a binary form, MSB first. Doesn't check for EOF.
char * ocropus::read_line_malloc (FILE *f)
 Read a line from the file, allocating memory with malloc().
bool ocropus::read_utf8 (colib::nustring &a, FILE *f)
 Read a line and decode it from utf-8.
void ocropus::text_read_1d (FILE *, colib::intarray &)
 Read a 1D intarray in a simple format: length and items.
void ocropus::text_write_1d (FILE *, colib::intarray &)
 Write a 1D intarray in a simple format: length and items.
void ocropus::write_checkpoint (FILE *f, const char *)
 Write a `checkpoint' to the file. A checkpoint is just some text lying around for 4 purposes:
  • after fscanf() it's unwise to use binary I/O, but after a checkpoint it's OK;
  • a checkpoint makes it easier to find stuff in the saved file
  • extra check when loading
  • versioning info can be stored in a checkpoint.

void ocropus::write_utf8 (FILE *f, colib::nustring &a)
 Write utf8-encoded string followed by a newline.
void ocropus::bin_read (colib::rectangle &r, FILE *f)
void ocropus::bin_read (FILE *f, colib::rectangle &r)
 Read a rectangle in a binary format.
void ocropus::bin_write (colib::rectangle &r, FILE *f)
void ocropus::bin_write (FILE *f, colib::rectangle &r)
 Write a rectangle in a binary format.
int ocropus::read_raw (colib::bytearray &a, FILE *f)
int ocropus::read_raw (FILE *f, colib::bytearray &a)
 Read a bytearray as fread() does. The number of bytes is determined by the array length.
void ocropus::text_read (colib::floatarray &a, FILE *f)
void ocropus::text_read (FILE *, colib::floatarray &)
 Read the array (with dimensions) from a text file.
void ocropus::text_write (colib::floatarray &a, FILE *f)
void ocropus::text_write (FILE *, colib::floatarray &)
 Write the array (with dimensions) into a text file.
void ocropus::write_int32 (FILE *f, int32_t n)
void ocropus::write_int32 (int32_t n, FILE *f)
 Write a 32-bit integer into the file in a binary form, MSB first.
int ocropus::write_raw (colib::bytearray &a, FILE *f)
int ocropus::write_raw (FILE *f, colib::bytearray &a)
 Write a bytearray as fwrite() does.

Generated by  Doxygen 1.6.0   Back to index