summaryrefslogtreecommitdiff
path: root/utils/synutils.h
diff options
context:
space:
mode:
authorWu, Ke <wuke@cs.umd.edu>2014-12-06 10:37:48 -0500
committerWu, Ke <wuke@cs.umd.edu>2014-12-06 10:37:48 -0500
commita21959213f9b1cc15befae52dbb5091e848de7a1 (patch)
treecd0359a322a8734f31e121860324314f1dc83eeb /utils/synutils.h
parent71fc7100b37b5bc2f5bbab414d90f9b3f19985c0 (diff)
Remove synutils.h
Diffstat (limited to 'utils/synutils.h')
-rw-r--r--utils/synutils.h123
1 files changed, 0 insertions, 123 deletions
diff --git a/utils/synutils.h b/utils/synutils.h
deleted file mode 100644
index f611553e..00000000
--- a/utils/synutils.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * utility.h
- *
- * Created on: Jun 24, 2013
- * Author: lijunhui
- */
-
-#ifndef UTILITY_H_
-#define UTILITY_H_
-
-#include <zlib.h>
-#include <stdio.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <string>
-#include <unordered_map>
-
-typedef std::unordered_map<std::string, int> MapString2Int;
-typedef std::unordered_map<std::string, float> MapString2Float;
-typedef std::unordered_map<std::string, float>::iterator
- MapString2FloatIterator;
-
-struct SFReader {
- SFReader() {}
- virtual ~SFReader() {}
-
- virtual bool fnReadNextLine(char* pszLine, int* piLength) = 0;
- virtual bool fnReadNextLine(std::string& strLine) = 0;
-};
-
-struct STxtFileReader : public SFReader {
- STxtFileReader(const char* pszFname) {
- m_fpIn = fopen(pszFname, "r");
- assert(m_fpIn != NULL);
- }
- ~STxtFileReader() {
- if (m_fpIn != NULL) fclose(m_fpIn);
- }
-
- bool fnReadNextLine(char* pszLine, int* piLength) {
- if (feof(m_fpIn) == true) return false;
-
- int iLen;
-
- pszLine[0] = '\0';
-
- fgets(pszLine, 10001, m_fpIn);
- iLen = strlen(pszLine);
- if (iLen == 0) return false;
- while (iLen > 0 && pszLine[iLen - 1] > 0 && pszLine[iLen - 1] < 33) {
- pszLine[iLen - 1] = '\0';
- iLen--;
- }
-
- if (piLength != NULL) (*piLength) = iLen;
-
- return true;
- }
-
- bool fnReadNextLine(std::string& strLine) {
- char* pszLine = new char[10001];
- bool bOut = fnReadNextLine(pszLine, NULL);
- if (bOut)
- strLine = std::string(pszLine);
- else
- strLine = std::string("");
- delete[] pszLine;
-
- return bOut;
- }
-
- private:
- FILE* m_fpIn;
-};
-
-struct SGZFileReader : public SFReader {
- SGZFileReader(const char* pszFname) {
- m_fpIn = gzopen(pszFname, "r");
- assert(m_fpIn != NULL);
- }
- ~SGZFileReader() {
- if (m_fpIn != NULL) gzclose(m_fpIn);
- }
-
- bool fnReadNextLine(char* pszLine, int* piLength) {
- if (m_fpIn == NULL) exit(0);
- if (gzeof(m_fpIn) == true) return false;
-
- int iLen;
-
- pszLine[0] = '\0';
-
- gzgets(m_fpIn, pszLine, 10001);
- iLen = strlen(pszLine);
- while (iLen > 0 && pszLine[iLen - 1] > 0 && pszLine[iLen - 1] < 33) {
- pszLine[iLen - 1] = '\0';
- iLen--;
- }
-
- if (piLength != NULL) (*piLength) = iLen;
-
- return true;
- }
-
- bool fnReadNextLine(std::string& strLine) {
- char* pszLine = new char[10001];
- bool bOut = fnReadNextLine(pszLine, NULL);
- if (bOut)
- strLine = std::string(pszLine);
- else
- strLine = std::string("");
- delete[] pszLine;
-
- return bOut;
- }
-
- private:
- gzFile m_fpIn;
-};
-
-#endif /* UTILITY_H_ */