Guest User

Untitled

a guest
May 16th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.15 KB | None | 0 0
  1. /*
  2. Copyright (c) 2012, Daniel Bocksteger
  3. All rights reserved.
  4.  
  5. Redistribution and use in source and binary forms, with or without
  6. modification, are permitted provided that the following condition is met:
  7. * Redistributions of source code must retain the above copyright
  8. notice and the following disclaimer.
  9.  
  10.  
  11. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  12. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  13. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  14. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
  15. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  16. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  19. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  20. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21. */
  22.  
  23.  
  24. #include <iostream>
  25. #include "StringOperations.hpp"
  26. #include "XMLWriter.hpp"
  27.  
  28. using namespace std;
  29.  
  30. int main(void) {
  31.     string receivers_string, reason, message;
  32.  
  33.     cout << "Bitte geben sie die Empfaenger mit ',' getrennt ein: ";
  34.     getline(cin, receivers_string);
  35.  
  36.     cout << "\nBitte geben sie einen Betreff ein: ";
  37.     getline(cin, reason);
  38.  
  39.     cout << "\nBitte geben sie ihr Nachricht ein: ";
  40.     getline(cin, message);
  41.  
  42.     StringVector list = split(receivers_string, ',', true);
  43.    
  44.     // Build the xml-structure
  45.     XMLWriter writer;
  46.     writer.createTag("sms");            // open root-tag 'sms'
  47.     writer.addComment("Contacts");
  48.     writer.createTag("contacts");       // creates tag 'contacts'
  49.     int i = 0;
  50.     for(StringVector::iterator it = list.begin(); it < list.end(); it++)    //Iterates through all findings
  51.     {
  52.             writer.addValue("receiver", *it);
  53.     }
  54.     writer.closeTag();                  // closes tag 'contacts'
  55.     writer.addComment("Reason");
  56.     writer.createTag("reason-tag");         // creates tag 'reason'
  57.     writer.addValue("reason-element", reason);
  58.     writer.closeTag();                  // closes tag 'reason'
  59.     writer.addComment("Message");
  60.     writer.createTag("message-tag");    // opens tag 'message'
  61.     writer.addValue("message-element", message);
  62.     writer.closeTag();                  // closes tag 'message'
  63.     writer.closeTag();                  // closes tag 'sms'
  64.  
  65.     //------- Dump XML to the Console ------------
  66.     cout << "----- xml begin -----\n";
  67.     cout << writer.toString();
  68.     cout << "------ xml end ------\n";
  69.  
  70.  
  71.     writer.saveAsFile("C:\\Users\\Daniel\\Documents\\sms-designs\\design.xml"); // ----- HIER BUGGTS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  72.    
  73.    
  74.     // Menu
  75.     int selection;
  76.     cout << "-----------------------\n";
  77.     cout << "- Menu                -\n";
  78.     cout << "- Datei speichern - 1 -\n";
  79.     cout << "- Neuer Entwurf   - 2 -\n";
  80.     cout << "- Beenden         - 3 -\n";
  81.     cout << "-----------------------\n";
  82.     cout << "- Ihre Wahl: ";
  83.     cin >> selection;
  84.  
  85.     switch(selection) {
  86.     case 1:
  87.         cout << "Menuepunkt 1 !";
  88.         break;
  89.     case 2:
  90.         cout << "Menuepunkt 2 !";
  91.         break;
  92.     case 3:
  93.         exit(1);
  94.         break;
  95.     default:
  96.         cout << "Falsche Eingabe !";
  97.     }
  98.  
  99.  
  100.     system("pause");
  101.  
  102.     return 0;
  103. }
Add Comment
Please, Sign In to add comment