Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <memory>
  4. #include <fstream>
  5. #include "bencoding.h"
  6. #include "Decoder.h"
  7. #include "BItem.h"
  8. #include "BDictionary.h"
  9. #include "PrettyPrinter.h"
  10.  
  11. using namespace std;
  12. using namespace bencoding;
  13.  
  14. int main ()
  15. {
  16.     ifstream myReadFile;
  17.      myReadFile.open("sample1.torrent");
  18.      char output[200];
  19.      if (myReadFile.is_open()) {
  20.      while (!myReadFile.eof()) {
  21.  
  22.         myReadFile >> output;
  23.         cout<<output;        
  24.     }
  25.  
  26.     try {
  27.             // Read and decode input data from the standard input.
  28.             std::shared_ptr<BItem> decodedData = decode(output);
  29.  
  30.             // Print the decoded data in a readable way to the standard output.
  31.             std::cout << getPrettyRepr(decodedData) << "\n";
  32.  
  33.             return 0;
  34.         } catch (const DecodingError &ex) {
  35.             // There was an error during the decoding.
  36.             std::cerr << "error: " << ex.what() << "\n";
  37.             return 1;
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement