mirror of
				https://github.com/aportelli/LatAnalyze.git
				synced 2025-11-04 00:04:31 +00:00 
			
		
		
		
	function to read file lists and progress bar class
This commit is contained in:
		@@ -78,20 +78,9 @@ void Dataset<T>::load(const std::string &listFileName,
 | 
				
			|||||||
                      const std::string &dataName)
 | 
					                      const std::string &dataName)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    FileType file;
 | 
					    FileType file;
 | 
				
			||||||
    std::ifstream listFile;
 | 
					 | 
				
			||||||
    char dataFileNameBuf[MAX_PATH_LENGTH];
 | 
					 | 
				
			||||||
    std::vector<std::string> dataFileName;
 | 
					    std::vector<std::string> dataFileName;
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    listFile.open(listFileName, std::ios::in);
 | 
					    dataFileName = readManifest(listFileName);
 | 
				
			||||||
    while (!listFile.eof())
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        listFile.getline(dataFileNameBuf, MAX_PATH_LENGTH);
 | 
					 | 
				
			||||||
        if (!std::string(dataFileNameBuf).empty())
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            dataFileName.push_back(dataFileNameBuf);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    listFile.close();
 | 
					 | 
				
			||||||
    this->resize(dataFileName.size());
 | 
					    this->resize(dataFileName.size());
 | 
				
			||||||
    for (Index i = 0; i < static_cast<Index>(dataFileName.size()); ++i)
 | 
					    for (Index i = 0; i < static_cast<Index>(dataFileName.size()); ++i)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,3 +31,22 @@ const string Env::msgPrefix = "[" + strFrom(PACKAGE_NAME) + " v"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void Env::function(void)
 | 
					void Env::function(void)
 | 
				
			||||||
{}
 | 
					{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ostream & Latan::operator<<(ostream &out, const ProgressBar &&bar)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    const Index nTick = bar.nCol_*bar.current_/bar.total_;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    out << "[";
 | 
				
			||||||
 | 
					    for (Index i = 0; i < nTick; ++i)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        out << "=";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    for (Index i = nTick; i < bar.nCol_; ++i)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        out << " ";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    out << "] " << bar.current_ << "/" << bar.total_;
 | 
				
			||||||
 | 
					    out.flush();
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    return out;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,6 +25,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <LatAnalyze/Eigen/Dense>
 | 
					#include <LatAnalyze/Eigen/Dense>
 | 
				
			||||||
#include <complex>
 | 
					#include <complex>
 | 
				
			||||||
 | 
					#include <fstream>
 | 
				
			||||||
 | 
					#include <iostream>
 | 
				
			||||||
#include <memory>
 | 
					#include <memory>
 | 
				
			||||||
#include <string>
 | 
					#include <string>
 | 
				
			||||||
#include <sstream>
 | 
					#include <sstream>
 | 
				
			||||||
@@ -240,6 +242,48 @@ inline IVec strTo<IVec>(const std::string &str)
 | 
				
			|||||||
    return res;
 | 
					    return res;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Manifest file reader ////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					inline std::vector<std::string> readManifest(const std::string manFileName)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    std::vector<std::string> list;
 | 
				
			||||||
 | 
					    std::ifstream            manFile;
 | 
				
			||||||
 | 
					    char                     buf[MAX_PATH_LENGTH];
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    manFile.open(manFileName);
 | 
				
			||||||
 | 
					    while (!manFile.eof())
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        manFile.getline(buf, MAX_PATH_LENGTH);
 | 
				
			||||||
 | 
					        if (!std::string(buf).empty())
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            list.push_back(buf);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    manFile.close();
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    return list;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Progress bar class //////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					class ProgressBar
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    // constructor
 | 
				
			||||||
 | 
					    template <typename A, typename B>
 | 
				
			||||||
 | 
					    ProgressBar(const A current, const B total, const Index nCol = 60);
 | 
				
			||||||
 | 
					    // IO
 | 
				
			||||||
 | 
					    friend std::ostream & operator<<(std::ostream &out,
 | 
				
			||||||
 | 
					                                     const ProgressBar &&bar);
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					    Index current_, total_, nCol_;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <typename A, typename B>
 | 
				
			||||||
 | 
					ProgressBar::ProgressBar(const A current, const B total, const Index nCol)
 | 
				
			||||||
 | 
					: current_(static_cast<Index>(current))
 | 
				
			||||||
 | 
					, total_(static_cast<Index>(total))
 | 
				
			||||||
 | 
					, nCol_(nCol)
 | 
				
			||||||
 | 
					{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
END_NAMESPACE
 | 
					END_NAMESPACE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <LatAnalyze/Exceptions.hpp>
 | 
					#include <LatAnalyze/Exceptions.hpp>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user