SHOGUN
v3.2.0
|
00001 #include <shogun/lib/SGStringList.h> 00002 #include <shogun/lib/SGString.h> 00003 #include <shogun/io/File.h> 00004 00005 namespace shogun 00006 { 00007 00008 template <class T> 00009 SGStringList<T>::SGStringList() : SGReferencedData() 00010 { 00011 init_data(); 00012 } 00013 00014 template <class T> 00015 SGStringList<T>::SGStringList(SGString<T>* s, index_t num_s, index_t max_length, 00016 bool ref_counting) : 00017 SGReferencedData(ref_counting), num_strings(num_s), 00018 max_string_length(max_length), strings(s) 00019 { 00020 } 00021 00022 template <class T> 00023 SGStringList<T>::SGStringList(index_t num_s, index_t max_length, bool ref_counting) : 00024 SGReferencedData(ref_counting), 00025 num_strings(num_s), max_string_length(max_length) 00026 { 00027 strings=SG_MALLOC(SGString<T>, num_strings); 00028 } 00029 00030 template <class T> 00031 SGStringList<T>::SGStringList(const SGStringList &orig) : 00032 SGReferencedData(orig) 00033 { 00034 copy_data(orig); 00035 } 00036 00037 template <class T> 00038 SGStringList<T>::~SGStringList() 00039 { 00040 unref(); 00041 } 00042 00043 template<class T> void SGStringList<T>::load(CFile* loader) 00044 { 00045 ASSERT(loader) 00046 unref(); 00047 00048 SG_SET_LOCALE_C; 00049 loader->get_string_list(strings, num_strings, max_string_length); 00050 SG_RESET_LOCALE; 00051 } 00052 00053 template<class T> void SGStringList<T>::save(CFile* saver) 00054 { 00055 ASSERT(saver) 00056 00057 SG_SET_LOCALE_C; 00058 saver->set_string_list(strings, num_strings); 00059 SG_RESET_LOCALE; 00060 } 00061 00062 00063 template <class T> 00064 void SGStringList<T>::copy_data(const SGReferencedData &orig) 00065 { 00066 strings = ((SGStringList*)(&orig))->strings; 00067 num_strings = ((SGStringList*)(&orig))->num_strings; 00068 max_string_length = ((SGStringList*)(&orig))->max_string_length; 00069 } 00070 00071 template <class T> 00072 void SGStringList<T>::init_data() 00073 { 00074 strings = NULL; 00075 num_strings = 0; 00076 max_string_length = 0; 00077 } 00078 00079 template <class T> 00080 void SGStringList<T>::free_data() 00081 { 00082 SG_FREE(strings); 00083 00084 strings = NULL; 00085 num_strings = 0; 00086 max_string_length = 0; 00087 } 00088 00089 template class SGStringList<bool>; 00090 template class SGStringList<char>; 00091 template class SGStringList<int8_t>; 00092 template class SGStringList<uint8_t>; 00093 template class SGStringList<int16_t>; 00094 template class SGStringList<uint16_t>; 00095 template class SGStringList<int32_t>; 00096 template class SGStringList<uint32_t>; 00097 template class SGStringList<int64_t>; 00098 template class SGStringList<uint64_t>; 00099 template class SGStringList<float32_t>; 00100 template class SGStringList<float64_t>; 00101 template class SGStringList<floatmax_t>; 00102 }