Subversion Repositories HomeAutomation

Rev

Rev 1914 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1914 Rev 1989
Line 41... Line 41...
41
 
41
 
42
}
42
}
43
 
43
 
44
void Node::LoadFile(std::string filename)
44
void Node::LoadFile(std::string filename)
45
{
45
{
46
    std::ifstream srcfile(filename.data());
46
  std::ifstream file(filename.data());
47
       
47
 
48
    if (!srcfile.is_open())
48
  if (!file.is_open())
49
    {
49
  {
50
        srcfile.close();
-
 
51
        throw std::runtime_error("Could not find " + filename);
50
    throw std::runtime_error("Could not find " + filename);
52
        return;
51
    return;
53
    }
52
  }
54
   
53
 
55
    std::string buffer = "";
54
  std::string buffer((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
56
    std::string line;
-
 
57
   
55
 
58
    while (!srcfile.eof())
-
 
59
    {
-
 
60
        std::getline(srcfile, line);
-
 
61
       
-
 
62
        if (srcfile.eof())
-
 
63
        {
-
 
64
            break;
-
 
65
        }
-
 
66
       
-
 
67
        buffer += line + "\n";
-
 
68
    }
-
 
69
   
-
 
70
    srcfile.close();
56
  file.close();
71
   
57
 
72
    this->Parse(buffer);
58
  this->Parse(buffer);
73
}
59
}
74
 
60
 
75
void Node::Parse(std::string data)
61
void Node::Parse(std::string data)