DtMmdb: replace ostring with std::string.

This commit is contained in:
hyousatsu
2024-07-05 06:06:27 -04:00
parent ba49a9e161
commit c79224b367
26 changed files with 71 additions and 514 deletions

View File

@@ -48,9 +48,10 @@
*/
#include "utility/debug.h"
#include "compression/code.h"
encoding_unit::encoding_unit(ostring* w, unsigned int f) :
encoding_unit::encoding_unit(std::string* w, unsigned int f) :
word(w), bits(0), freq(f), code(0), leaf_htr_node(NULL)
{
}
@@ -60,7 +61,7 @@ encoding_unit::~encoding_unit()
delete word;
}
ostream& operator<<(ostream& out, encoding_unit& eu)
std::ostream& operator<<(std::ostream& out, encoding_unit& eu)
{
debug(out, *eu.word);
debug(out, eu.freq);

View File

@@ -51,7 +51,8 @@
#ifndef _code_h
#define _code_h 1
#include "utility/ostring.h"
#include <string>
////////////////////////////////////////
//
////////////////////////////////////////
@@ -61,17 +62,17 @@ class htr_node;
class encoding_unit
{
public:
ostring* word;
std::string* word;
int bits;
unsigned int freq;
unsigned int code;
htr_node* leaf_htr_node;
public:
encoding_unit(ostring* w, unsigned int freq);
encoding_unit(std::string* w, unsigned int freq);
~encoding_unit();
friend ostream& operator <<(ostream&, encoding_unit&);
friend std::ostream& operator <<(std::ostream&, encoding_unit&);
};

View File

@@ -310,7 +310,7 @@ void huff::compress(const buffer& uncompressed, buffer& compressed)
void huff::decompress(buffer& compressed, buffer& uncompressed)
{
char* buf_base = uncompressed.get_base();
char* str;
const char* str;
int str_len;
char rem_bits;
@@ -339,7 +339,7 @@ void huff::decompress(buffer& compressed, buffer& uncompressed)
//}
str_len = node_ptr -> eu -> word -> size();
str = node_ptr -> eu -> word -> get();
str = node_ptr -> eu -> word -> c_str();
if ( str_len == 1 ) {
@@ -379,8 +379,8 @@ void huff::decompress(buffer& compressed, buffer& uncompressed)
uncompressed.set_content_sz(buf_base-uncompressed.get_base());
if ( rem_bits > 0 )
uncompressed.put( node_ptr -> eu -> word -> get(),
node_ptr -> eu -> word -> size()
uncompressed.put( node_ptr -> eu -> word -> c_str(),
node_ptr -> eu -> word -> size()
);
}
@@ -422,7 +422,7 @@ io_status huff::cdrOut(buffer& buf)
word_sz = e_units[i] -> word -> size();
v_out_buf.put(char(word_sz));
v_out_buf.put(e_units[i] -> word -> get(), word_sz);
v_out_buf.put(e_units[i] -> word -> c_str(), word_sz);
v_out_buf.put(e_units[i] -> freq);
}

View File

@@ -221,7 +221,7 @@ void trie::add(unsigned char* word, int sz, int fq)
encoding_unit* trie::add_to_alphabet(unsigned char* word, int sz, int fq)
{
extend_alphabet();
encoding_unit *x = new encoding_unit(new ostring((char*)word, sz), fq);
encoding_unit *x = new encoding_unit(new string((char*)word, sz), fq);
alphabet[alphabet_sz++] = x;
return x;
}
@@ -240,7 +240,7 @@ cerr << "\n";
static trie_node_info* y = 0;
static char buf[1];
static ostring *z;
static string *z;
if ( root == 0 )
root = new trie_node(0);
@@ -261,7 +261,7 @@ cerr << "\n";
y -> info.info_view.letter = j;
buf[0] = char(j);
z = new ostring(buf, 1);
z = new string(buf, 1);
y -> info.info_view.mark = 1;
extend_alphabet();
@@ -292,7 +292,7 @@ void update_index(int ind, void* x)
void trie::_find_leaf(trie_node* z, int& j)
{
trie_node_info* x = 0;
ostring *y;
string *y;
for ( int i=0; i<LANG_ALPHABET_SZ; i++ ) {
#ifdef C_API
@@ -322,7 +322,7 @@ encoding_unit** trie::get_alphabet(unsigned int& a_sz)
return alphabet;
}
ostring* trie::get_word(trie_node_info* leaf)
string* trie::get_word(trie_node_info* leaf)
{
static char buf[128];
buf[127] = 0;
@@ -343,7 +343,7 @@ ostring* trie::get_word(trie_node_info* leaf)
}
//debug(cerr, buf+i);
return new ostring(buf+i, 127-i);
return new string(buf+i, 127-i);
}
Boolean trie::travers_to(char* str, int len,

View File

@@ -130,7 +130,7 @@ protected:
protected:
void collect_freqs(trie_node* rt, int level);
ostring* get_word(trie_node_info* x);
string* get_word(trie_node_info* x);
void _find_leaf(trie_node* z, int& j);
void extend_alphabet();