ReadonlyTextFileStream Class Reference

ReadonlyTextFileStream Class Reference

#include <readonlytextfilestream.h>

Class Description

ReadonlyTextFileStream is only used for opening text file in read-only mode.

It's equivalent to use FileStream when opening files in "rt" mode. But FileStream is very slow when reading files. So we optimize the original codes in FileStream and create this new class which is thousand times faster for reading text files than FileStream.

Note
Invoke any non-read-only methods in ReadonlyTextFileStream will result in a runtime exception. Such methods include putch(),puts(),printf().
+ Inheritance diagram for ReadonlyTextFileStream:

Public Member Functions

ScripterExport ReadonlyTextFileStream ()
 The default constructor. More...
 
ScripterExport ~ReadonlyTextFileStream ()
 The default destructor. More...
 
ScripterExport ReadonlyTextFileStream * open (const MCHAR *ifile_name, unsigned int encoding=-1)
 Open a new text file. More...
 
MaxSDK::Util::Char get_char ()
 
void unget_char (const MaxSDK::Util::Char &c)
 
MaxSDK::Util::Char peek_char ()
 
int at_eos ()
 
unsigned int pos ()
 
void seek (int pos)
 
void rewind ()
 
void flush_to_eol ()
 
MaxSDK::Util::Char putch (const MaxSDK::Util::Char &c)
 
const MCHAR * puts (const MCHAR *str)
 
int printf (const MCHAR *format,...)
 
void collect ()
 
void close ()
 
void gc_trace ()
 
void log_to (CharStream *log)
 
void close_log ()
 
CharStream * get_log ()
 
- Public Member Functions inherited from CharStream
ScripterExport CharStream ()
 
virtual ScripterExport ~CharStream ()
 
 classof_methods (CharStream, Value)
 
BOOL _is_charstream ()
 
virtual unsigned int line ()
 
virtual void flush_to_eobuf ()
 
virtual void flush_whitespace ()
 
virtual void flush ()
 
virtual Listener * get_listener ()
 
virtual Value * get_file_name ()
 
virtual void set_file_name (const MCHAR *fileName)
 
virtual CharStream * get_resource_value_stream (Value *resourceID)
 
- Public Member Functions inherited from Value
virtual ScripterExport BOOL is_kind_of (ValueMetaClass *c)
 
virtual ScripterExport ValueMetaClass * local_base_class ()
 
virtual Value * eval ()
 
virtual Value * eval_no_wrapper ()
 
virtual ScripterExport Value * apply (Value **arglist, int count, CallContext *cc=NULL)
 
virtual ScripterExport Value * apply_no_alloc_frame (Value **arglist, int count, CallContext *cc=NULL)
 
virtual void export_to_scripter ()
 
virtual Value * map (node_map &m)
 
virtual Value * map_path (PathName *path, node_map &m)
 
virtual Value * find_first (BOOL(*test_fn)(INode *node, int level, const void *arg), const void *test_arg)
 
virtual Value * get_path (PathName *path)
 
virtual ScripterExport void sprin1 (CharStream *stream)
 
virtual ScripterExport void sprint (CharStream *stream)
 
virtual void prin1 ()
 
virtual void print ()
 
virtual ScripterExport Class_ID get_max_class_id ()
 
virtual ScripterExport Value * delete_vf (Value **arglist, int arg_count)
 
virtual ScripterExport Value * clearSelection_vf (Value **arglist, int arg_count)
 
virtual float to_float ()
 
virtual double to_double ()
 
virtual const MCHAR * to_string ()
 
virtual MSTR to_mstr ()
 
virtual MSTR to_filename ()
 
virtual int to_int ()
 
virtual INT64 to_int64 ()
 
virtual INT_PTR to_intptr ()
 
virtual BOOL to_bool ()
 
virtual BitArray & to_bitarray ()
 
virtual Point4 to_point4 ()
 
virtual Point3 to_point3 ()
 
virtual Point2 to_point2 ()
 
virtual AColor to_acolor ()
 
virtual COLORREF to_colorref ()
 
virtual INode * to_node ()
 
virtual Ray to_ray ()
 
virtual Interval to_interval ()
 
virtual Quat to_quat ()
 
virtual AngAxis to_angaxis ()
 
virtual Matrix3 & to_matrix3 ()
 
virtual float * to_eulerangles ()
 
virtual Mtl * to_mtl ()
 
virtual Texmap * to_texmap ()
 
virtual MtlBase * to_mtlbase ()
 
virtual Modifier * to_modifier ()
 
virtual TimeValue to_timevalue ()
 
virtual Control * to_controller ()
 
virtual Atmospheric * to_atmospheric ()
 
virtual Effect * to_effect ()
 
virtual IMultiPassCameraEffect * to_mpassCamEffect ()
 
virtual ShadowType * to_shadowtype ()
 
virtual FilterKernel * to_filter ()
 
virtual INode * to_rootnode ()
 
virtual ITrackViewNode * to_trackviewnode ()
 
virtual NURBSIndependentPoint * to_nurbsindependentpoint ()
 
virtual NURBSPoint * to_nurbspoint ()
 
virtual NURBSObject * to_nurbsobject ()
 
virtual NURBSControlVertex * to_nurbscontrolvertex ()
 
virtual NURBSCurve * to_nurbscurve ()
 
virtual NURBSCVCurve * to_nurbscvcurve ()
 
virtual NURBSSurface * to_nurbssurface ()
 
virtual NURBSTexturePoint * to_nurbstexturepoint ()
 
virtual NURBSSet * to_nurbsset ()
 
virtual ReferenceTarget * to_reftarg ()
 
virtual Mesh * to_mesh ()
 
virtual BezierShape * to_beziershape ()
 
virtual Thunk * to_thunk ()
 
virtual void to_fpvalue (FPValue &v)
 
virtual Renderer * to_renderer ()
 
virtual Box2 & to_box2 ()
 
virtual NURBSTextureSurface * to_nurbstexturesurface ()
 
virtual NURBSDisplay * to_nurbsdisplay ()
 
virtual TessApprox * to_tessapprox ()
 
virtual Value * widen_to (Value *arg, Value **arg_list)
 
virtual BOOL comparable (Value *arg)
 
virtual BOOL special_case_compare (Value *arg, bool &specialCaseCompareResult)
 
virtual ScripterExport Value * deep_copy (HashTable *remapper)
 
virtual BOOL is_const ()
 
virtual ScripterExport Value * get_property (Value **arg_list, int count)
 
virtual ScripterExport Value * set_property (Value **arg_list, int count)
 
ScripterExport Value * _get_property (Value *prop)
 
virtual ScripterExport Value * _set_property (Value *prop, Value *val)
 
virtual Value * get_container_property (Value *prop, Value *cur_prop)
 
virtual Value * set_container_property (Value *prop, Value *val, Value *cur_prop)
 
virtual BOOL _is_collection ()
 
virtual BOOL _is_rolloutcontrol ()
 
virtual BOOL _is_rolloutthunk ()
 
virtual BOOL _is_function ()
 
virtual BOOL _is_selection ()
 
virtual BOOL _is_thunk ()
 
virtual BOOL _is_indirect_thunk ()
 
virtual SelectionIterator * selection_iterator ()
 
virtual ScripterExport IOResult Save (ISave *isave)
 
virtual void drop_MAX_refs ()
 
virtual BaseInterface * GetInterface (Interface_ID id)
 
ScripterExport Value * make_heap_permanent ()
 
ScripterExport Value * make_heap_static ()
 
ScripterExport Value * get_heap_ptr ()
 
ScripterExport Value * get_stack_heap_ptr ()
 
ScripterExport Value * migrate_to_heap ()
 
ScripterExport Value * get_live_ptr ()
 
- Public Member Functions inherited from Collectable
ScripterExport Collectable ()
 
virtual ScripterExport ~Collectable ()
 
ScripterExport void * operator new (size_t sz, char flag)
 
ScripterExport void * operator new (size_t sz)
 
ScripterExport void operator delete (void *val)
 
ScripterExport void operator delete (void *val, char flag)
 
ScripterExport bool derives_from_Animatable ()
 
virtual BOOL derives_from_MAXWrapper ()
 
ScripterExport void make_collectable ()
 
void make_permanent ()
 
void make_static ()
 
int is_marked ()
 
int is_not_marked ()
 
int is_garbage ()
 
int is_permanent ()
 
void mark_in_use ()
 
void unmark_in_use ()
 
int has_heap_copy ()
 
int is_in_heap ()
 
int is_on_stack ()
 

Protected Attributes

int mUngetcharCount
 
MaxSDK::Util::Char mUngetcharBuf [8]
 
MaxSDK::Util::Char * mFileBuf
 
size_t mCharCount
 
size_t mCharPos
 
CharStream * mLog
 
- Protected Attributes inherited from CharStream
unsigned int mlineNumber
 
Value * file_name
 
HashTable * resourceMap
 
StringStream * resourceValueStream
 

Additional Inherited Members

- Static Public Member Functions inherited from Collectable
static ScripterExport void for_all_values (void(*map_fn)(Value *val), ValueMapper *mapper=NULL, ValueMetaClass *c=NULL)
 
static void mark ()
 
static void sweep ()
 
static void setup (size_t)
 
static ScripterExport void gc ()
 
static void coalesce_free_list ()
 
static void close_down ()
 
static void drop_maxwrapper_refs ()
 
static ScripterExport void push_alloc_stack_frame ()
 
static ScripterExport void pop_alloc_stack_frame ()
 
static ScripterExport ULONGLONG get_num_values_created ()
 
static ScripterExport bool validate_value_linkages ()
 
- Public Attributes inherited from Value
ValueMetaClass * tag
 
- Public Attributes inherited from Collectable
Collectable * next
 
Collectable * prev
 
byte flags
 
byte flags2
 
short flags3
 
- Static Public Attributes inherited from Collectable
static CRITICAL_SECTION heap_update
 
static Collectable * collectable_list
 
static Collectable * permanent_list
 
static free_mem * free_list [GC_NUM_SUBLISTS]
 
static size_t heap_allocated
 
static size_t heap_size
 
static ScripterExport collectable_state state
 
static ScripterExport bool fullCollectNextHoldFlush
 
static bool gc_light
 
static bool in_gc
 
static HANDLE hGCCompletedEvent
 

Constructor & Destructor Documentation

The default constructor.

The default destructor.

Member Function Documentation

ScripterExport ReadonlyTextFileStream* open ( const MCHAR *  ifile_name,
unsigned int  encoding = -1 
)

Open a new text file.

Parameters
[in]ifile_nameThe file name.
[in]encodingThe encoding to use if if can not be determined from the file contents, If -1, a default encoding based on the file language setting in Preference /Files (exposed through Interface14) will be used.
Returns
The ReadonlyTextFileStream instance itself if max is able to open the file or undefined if it fails.
MaxSDK::Util::Char get_char ( )
virtual

Implements CharStream.

void unget_char ( const MaxSDK::Util::Char &  c)
virtual

Implements CharStream.

MaxSDK::Util::Char peek_char ( )
virtual

Implements CharStream.

int at_eos ( )
virtual

Implements CharStream.

unsigned int pos ( )
virtual

Reimplemented from CharStream.

void seek ( int  pos)
virtual

Reimplemented from CharStream.

void rewind ( )
virtual

Implements CharStream.

void flush_to_eol ( )
virtual

Implements CharStream.

MaxSDK::Util::Char putch ( const MaxSDK::Util::Char &  c)
virtual

Reimplemented from CharStream.

const MCHAR* puts ( const MCHAR *  str)
virtual

Reimplemented from CharStream.

int printf ( const MCHAR *  format,
  ... 
)
virtual

Reimplemented from CharStream.

void collect ( )
virtual

Implements Collectable.

void close ( )
virtual

Reimplemented from CharStream.

void gc_trace ( )
virtual

Reimplemented from CharStream.

void log_to ( CharStream *  log)
virtual

Reimplemented from CharStream.

void close_log ( )
virtual

Reimplemented from CharStream.

CharStream* get_log ( )
virtual

Reimplemented from CharStream.

Member Data Documentation

int mUngetcharCount
protected
MaxSDK::Util::Char mUngetcharBuf[8]
protected
MaxSDK::Util::Char* mFileBuf
protected
size_t mCharCount
protected
size_t mCharPos
protected
CharStream* mLog
protected