📄 sof.h
字号:
// method: prev // long prev(const SysString& name, long cur_tag) { long name_ind = table_d.getIndex(name); return index_d.prev(name_ind, cur_tag); } // object put methods // boolean put(const SysString& name, long size); boolean put(const SysString& name, long tag, long size); // object remove methods // boolean remove(const SysString& name, long object_tag); boolean remove(long name, long object_tag); boolean remove(const SysString& name); boolean remove(long name); // object copy methods // boolean copy(long o_tag, Sof& i_sof, const SysString& i_cname, long i_tag); boolean copy(long o_tag, Sof& i_sof, long i_cname, long i_tag); boolean copy(Sof& i_sof, const SysString& i_cname); boolean copy(Sof& i_sof, long i_cname); // object operations: get methods // long getObjectSize(const SysString& name, long tag); long getObjectSize(); // index count methods // // method: getCount // this method gets the number of objects with this class name // long getCount(const SysString& name) { return index_d.getCount(table_d.getIndex(name)); } // method: getCount // long getCount() { return index_d.getCount(); } // method: getNameCount // this method gets the number of classes in the file, // note it only works because the index is sorted // long getNameCount() { return table_d.getCount(); } // method: enumerate // this method enumerates all objects in an sof file // boolean enumerate(SofList& index, SofSymbolTable& table) const { index.assign(index_d); table.assign(table_d); return true; } // positioning methods (relative to current object) // boolean seek(long offset, File::SEEK whence); long tell() const; // method: rewind // boolean rewind() { if (cur_data_d < 0) { return Error::handle(name(), L"rewind", SofList::ERR, __FILE__, __LINE__); } return fseek(cur_data_d, File::POS); } //--------------------------------------------------------------------------- // // class-specific public methods: // input and output methods // //--------------------------------------------------------------------------- // wrap the base i/o functions with automatic byte-swapping and // range checking. imagine each object within an Sof file is it's // own file, so rewind brings you to the beginning of that object's // space, not the begining of the actual file. // // binary i/o methods // long read(void* ptr, long size, long nitems); long write(const void* ptr, long size, long nitems); // text i/o methods // boolean gets(SysString& ptr, long size = BUFFER_SIZE); boolean puts(const SysString& ptr); // write label methods // boolean writeLabelPrefix(const SysString& param_name); boolean writeLabelSuffix(const SysString& param_name); //--------------------------------------------------------------------------- // // class-specific public methods: // formatting methods // //--------------------------------------------------------------------------- // these methods are for text sof file only. refer File class for // the meaning of these methods // // method: increaseIndention // boolean increaseIndention() { if (isText()) { return fp_d.increaseIndention(); } return false; } // method: decreaseIndention // boolean decreaseIndention() { if (isText()) { return fp_d.decreaseIndention(); } return false; } // method: setLineWrap // boolean setLineWrap(long ncols) { if (isText()) { return fp_d.setLineWrap(ncols); } return false; } // method: getLineLength // long getLineLength() const { if (isText()) { return fp_d.getLineLength(); // only for text files } return -1; // exit ungracefully } // method: getLineWrap // long getLineWrap() const { if (isText()) { return fp_d.getLineWrap(); } return -1; } //--------------------------------------------------------------------------- // // class-specific public methods: // methods that facilitate partial i/o // //--------------------------------------------------------------------------- // partial write configuration methods // // methods to facilitate partial i/o // boolean startPartialWrite(); boolean stopPartialWrite(); boolean startPartialRead(); boolean stopPartialRead(); // method: getSkipTable // int32* getSkipTable() { if ((!partial_write_d) && (!partial_read_d)) { Error::handle(name(), L"getSkipTable", ERR, __FILE__, __LINE__); } return skip_table_d; } // method: getSkipTable // const int32* getSkipTable() const { if ((!partial_write_d) && (!partial_read_d)) { Error::handle(name(), L"getSkipTable", ERR, __FILE__, __LINE__); } return skip_table_d; } // method: getSkipTableIncr // long getSkipTableIncr() const { if ((!partial_write_d) && (!partial_read_d)) { return Error::handle(name(), L"getSkipTableIncr", ERR, __FILE__, __LINE__); } return skip_table_incr_d; } // method: getLastSkipTablePos // long getLastSkipTablePos() const { if ((!partial_write_d) && (!partial_read_d)) { return Error::handle(name(), L"getLastSkipTablePos", ERR, __FILE__, __LINE__); } return last_skip_table_pos_d; } // method: getStartPos // long getStartPos() const { if ((!partial_write_d) && (!partial_read_d)) { return Error::handle(name(), L"getStartPos", ERR, __FILE__, __LINE__); } return vec_start_pos_d; } // method: getVecSize // long getVecSize() const { if ((!partial_write_d) && (!partial_read_d)) { return Error::handle(name(), L"getVecSize", ERR, __FILE__, __LINE__); } return vec_size_d; } // method: getVecCurrentElement // long getVecCurrentElement() const { if ((!partial_write_d) && (!partial_read_d)) { return Error::handle(name(), L"getVecCurrentElement", ERR, __FILE__, __LINE__); } return vec_curr_elem_d; } // method: getVecParser // const SofParser& getVecParser() const; SofParser& getVecParser(); // method: setSkipTableIncr // boolean setSkipTableIncr(long pos) { if ((!partial_write_d) && (!partial_read_d)) { return Error::handle(name(), L"getSkipTableIncr", ERR, __FILE__, __LINE__); } skip_table_incr_d = pos; return true; } // method: setLastSkipTablePos // boolean setLastSkipTablePos(long pos) { if ((!partial_write_d) && (!partial_read_d)) { return Error::handle(name(), L"getLastSkipTablePos", ERR, __FILE__, __LINE__); } last_skip_table_pos_d = pos; return true; } // method: setStartPos // boolean setStartPos(long pos) { if ((!partial_write_d) && (!partial_read_d)) { return Error::handle(name(), L"setStartPos", ERR, __FILE__, __LINE__); } vec_start_pos_d = pos; return true; } // method: setVecSize // boolean setVecSize(long pos) { if ((!partial_write_d) && (!partial_read_d)) { return Error::handle(name(), L"setVecSize", ERR, __FILE__, __LINE__); } vec_size_d = pos; return true; } // method: setVecCurrentElement // boolean setVecCurrentElement(long pos) { if ((!partial_write_d) && (!partial_read_d)) { return Error::handle(name(), L"setVecCurrentElement", ERR, __FILE__, __LINE__); } vec_curr_elem_d = pos; return true; } // method: getPartialWrite // boolean getPartialWrite() const { return partial_write_d; } // method: getPartialRead // boolean getPartialRead() const { return partial_read_d; } // method: clearSkipTable // boolean clearSkipTable() { if (skip_table_d == (int32*)NULL) { return Error::handle(name(), L"clearSkipTable", Error::MEM, __FILE__, __LINE__); } for (long i = 0; i < SKIP_TABLE_GROUP; i++) { skip_table_d[i] = -1; } return true; } // method: writeSkipTable // boolean writeSkipTable() { if (skip_table_d == (int32*)NULL) { return Error::handle(name(), L"writeSkipTable", Error::MEM, __FILE__, __LINE__); } long n = write(skip_table_d, sizeof(int32), SKIP_TABLE_GROUP); return (n == SKIP_TABLE_GROUP); } // method: readSkipTable // boolean readSkipTable() { if (skip_table_d == (int32*)NULL) { return Error::handle(name(), L"writeSkipTable", Error::MEM, __FILE__, __LINE__); } last_skip_table_pos_d = tell(); long n = read(skip_table_d, sizeof(int32), SKIP_TABLE_GROUP); return (n == SKIP_TABLE_GROUP); } // resize entry methods (should only be called in partial write mode) // boolean resize(long size); //--------------------------------------------------------------------------- // // private methods // //---------------------------------------------------------------------------private: // method: copy constructor // the method is private so we can't copy Sof objects. // Sof(const Sof& arg) { Error::handle(name(), L"Sof Constructor", Error::BAD_CSTR, __FILE__, __LINE__); } // free memory methods // boolean cleanUp(); boolean freeIndex(); // update methods: // update index and header // boolean update(); // binary index i/o methods // boolean readIndex(); boolean writeIndex(); // symbol table i/o methods // boolean readTable(); boolean writeTable(); // open read methods: // these methods open an sof file for read access // boolean openRead(); // method: openReadText // boolean openReadText() { return openReadIndexText(); } // method: openReadBinary // boolean openReadBinary() { return openReadIndexBinary(); } // open read index methods: // these methods open a sof file for reading the indices // boolean openReadIndexText(); boolean openReadIndexBinary(); // open write methods: // these methods open an sof file for write access // boolean openWrite(File::MODE access_mode); // text file label handling methods // boolean writeLabel(long name, long tag); boolean writeLabel(const SysString& name, long tag); boolean parseLabel(SysString& name, long& tag, const SysString& buf); boolean skipLabel(); // method: seekData // these methods seek to the data of an object // boolean seekData() { if (file_type_d == File::TEXT) { return seekDataText(); } return seekDataBinary(); } boolean seekDataText(); boolean seekDataBinary(); // internal object manipulation methods: // the public interface is far simpler // boolean find(long name, long tag); boolean add(const SysString& name, long size, long tag = FREE_TAG); boolean add(long name, long size, long tag = FREE_TAG); // resize methods: // resize the current entry, preserving current data // boolean resize(const SysString& name, long tag, long size); // binary i/o methods: // read/write with byte swapping without range checking // long fwrite(const void* ptr, long size, long nitems); long fread(void* ptr, long size, long nitems); // position methods // boolean fseek(long offset, File::SEEK whence); long ftell() const; // copy segment methods: // efficient methods for clearing out a section of a file and // copying a section of a file from one place to another. // boolean clearSpace(long nbytes); boolean copySegment(long src_pos, long size); boolean copySegment(long src_pos, long dest_pos, long size); // error pointer setting methods // boolean setErrorPointer(); // register pointer maintaining methods: // maintain an array of all open Sof pointers (part of clean exit) // boolean registerPtr(); boolean unRegisterPtr(); //--------------------------------------------------------------------------- // // friend functions and classes: // while friend functions and classes are generally discouraged in the ISIP // environment, they are used in the Sof class to allow the // AudioFile class direct access to Sof's internals for efficiency. // //--------------------------------------------------------------------------- // class: AudioFile // friend class AudioFile;};// end of include file//#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -