From 32dba9570945bb0c37875b5224dbf02b6b007afc Mon Sep 17 00:00:00 2001 From: Timothy McCallum Date: Thu, 4 May 2017 09:15:18 +1000 Subject: [PATCH] Removing using namespace in the header This has been updated and is ready for deployment. No namespaces used in the header of the code now, just explicit calls in the functions. std::string, std::vector, std::clog, std::endl, xlnt::workbook. --- docs/introduction/Examples.md | 36 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/docs/introduction/Examples.md b/docs/introduction/Examples.md index 153023df..9185b5eb 100644 --- a/docs/introduction/Examples.md +++ b/docs/introduction/Examples.md @@ -6,22 +6,20 @@ The following C plus plus code will read the values from an xlsx file and print #include #include -using namespace std; -using namespace xlnt; int main() { - workbook wb; + xlnt::workbook wb; wb.load("/home/timothymccallum/test.xlsx"); auto ws = wb.active_sheet(); - clog << "Processing spread sheet" << endl; + std::clog << "Processing spread sheet" << std::endl; for (auto row : ws.rows(false)) { for (auto cell : row) { - clog << cell.to_string() << endl; + std::clog << cell.to_string() << std::endl; } } - clog << "Processing complete" << endl; + std::clog << "Processing complete" << std::endl; return 0; } ``` @@ -57,37 +55,33 @@ Loading a spread sheet into a Vector provides oppourtunities for you to perform #include #include -using namespace std; -using namespace xlnt; - - int main() { - workbook wb; + xlnt::workbook wb; wb.load("/home/timothymccallum/test.xlsx"); auto ws = wb.active_sheet(); - clog << "Processing spread sheet" << endl; - clog << "Creating a single vector which stores the whole spread sheet" << endl; - vector< vector > theWholeSpreadSheet; + std::clog << "Processing spread sheet" << std::endl; + std::clog << "Creating a single vector which stores the whole spread sheet" << std::endl; + std::vector< std::vector > theWholeSpreadSheet; for (auto row : ws.rows(false)) { - clog << "Creating a fresh vector for just this row in the spread sheet" << endl; - vector aSingleRow; + std::clog << "Creating a fresh vector for just this row in the spread sheet" << std::endl; + std::vector aSingleRow; for (auto cell : row) { - clog << "Adding this cell to the row" << endl; + std::clog << "Adding this cell to the row" << std::endl; aSingleRow.push_back(cell.to_string()); } - clog << "Adding this entire row to the vector which stores the whole spread sheet" << endl; + std::clog << "Adding this entire row to the vector which stores the whole spread sheet" << std::endl; theWholeSpreadSheet.push_back(aSingleRow); } - clog << "Processing complete" << endl; - clog << "Reading the vector and printing output to the screen" << endl; + std::clog << "Processing complete" << std::endl; + std::clog << "Reading the vector and printing output to the screen" << std::endl; for (int rowInt = 0; rowInt < theWholeSpreadSheet.size(); rowInt++) { for (int colInt = 0; colInt < theWholeSpreadSheet.at(rowInt).size(); colInt++) { - cout << theWholeSpreadSheet.at(rowInt).at(colInt) << endl; + std::cout << theWholeSpreadSheet.at(rowInt).at(colInt) << std::endl; } } return 0;