Revision: 1396
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1396&view=rev
Author: rorthomas
Date: 2010-05-22 22:25:43 +0000 (Sat, 22 May 2010)
Log Message:
-----------
comment and description sections working.
explicit section end behavior changed.
Modified Paths:
--------------
trunk/source/serializer/serializationmodules.cpp
trunk/source/serializer/serializer.cpp
trunk/source/serializer/serializer.h
Modified: trunk/source/serializer/serializationmodules.cpp
===================================================================
--- trunk/source/serializer/serializationmodules.cpp 2010-05-22 16:21:16 UTC
(rev 1395)
+++ trunk/source/serializer/serializationmodules.cpp 2010-05-22 22:25:43 UTC
(rev 1396)
@@ -607,6 +607,10 @@
if(linestr == activeSection)
return 1;
+ // comment section ignored
+ if(activeSection == "comment")
+ return 1;
+
if(activeSection == "description")
{
if(strlen(rig->fileinfo->description) + strlen(line) < 9045)
Modified: trunk/source/serializer/serializer.cpp
===================================================================
--- trunk/source/serializer/serializer.cpp 2010-05-22 16:21:16 UTC (rev
1395)
+++ trunk/source/serializer/serializer.cpp 2010-05-22 22:25:43 UTC (rev
1396)
@@ -48,7 +48,7 @@
// file things
char line[1024];
int linecounter = 0;
- std::string activeSection;
+ std::string activeSection, previousSection;
bool activeSectionExplicit = false;
// read in truckname
@@ -71,7 +71,7 @@
// now process the modules and try to parse the line
// -1 = error, 0 = no match, > 0 = n matches
- int res = processModules(line, rig, &ctx, activeSection,
activeSectionExplicit);
+ int res = processModules(line, rig, &ctx, activeSection,
previousSection, activeSectionExplicit);
if(!activeSection.empty() && res == 0)
{
LogManager::getSingleton().logMessage("line section
parsing with no result: " + String(line));
@@ -120,7 +120,7 @@
commands[command] = module;
}
-int RoRSerializer::processModules(char *line, rig_t *rig, SerializationContext
*ctx, std::string &activeSection, bool &activeSectionExplicit)
+int RoRSerializer::processModules(char *line, rig_t *rig, SerializationContext
*ctx, std::string &activeSection, std::string &previousSection, bool
&activeSectionExplicit)
{
std::string linestr = std::string(line);
// parse for commands
@@ -141,37 +141,44 @@
}
}
- // parse for sections
- for(it = sections.begin(); it != sections.end() ; it++)
+ // parse for sections if the current section is non explicit
+ if(!activeSectionExplicit)
{
- if(!it->first.size()) continue;
- // check for a new section
- if(!activeSectionExplicit && it->first == linestr || "=" +
it->first == linestr)
+ for(it = sections.begin(); it != sections.end() ; it++)
{
- // match, using this module
- //set section as active
- activeSection = it->first;
+ if(!it->first.size()) continue;
+ // check for a new section
+ if(it->first == linestr || "=" + it->first == linestr)
+ {
+ // match, using this module
+ //set section as active
+ previousSection = activeSection;
+ activeSection = it->first;
- // find out whether its explicit
- activeSectionExplicit =
(explictSections.find(activeSection) != explictSections.end());
- // parse this as well, could be that the section header
contains information as well
- return it->second->deserialize(line, rig,
activeSection);
+ // find out whether its explicit
+ activeSectionExplicit =
(explictSections.find(activeSection) != explictSections.end());
+
+ // parse this as well, could be that the
section header contains information as well
+ return it->second->deserialize(line, rig,
activeSection);
+ }
}
+ }
- // check for a section end
- if("end_" + it->first == linestr || "=end_"+it->first ==
linestr)
+ // if we are in a section, parse it in its module handler
+ if(!activeSection.empty())
+ {
+ // check for active section end
+ if("end_" + activeSection == linestr || "=end_" + activeSection
== linestr)
{
// found section end
- activeSection = std::string();
+ // restore previous section if closed explicitly
+ activeSection = previousSection;
+ previousSection = "";
activeSectionExplicit = false;
return 1;
}
- }
- // if we are in a section, parse it in its module handler
- if(!activeSection.empty())
- {
// just try to use that section and ignore the others
return sections[activeSection]->deserialize(line, rig,
activeSection);
}
Modified: trunk/source/serializer/serializer.h
===================================================================
--- trunk/source/serializer/serializer.h 2010-05-22 16:21:16 UTC (rev
1395)
+++ trunk/source/serializer/serializer.h 2010-05-22 22:25:43 UTC (rev
1396)
@@ -66,7 +66,7 @@
RoRSerializationModule *getSectionModule(rig_t *rig, std::string
section);
protected:
- int processModules(char *line, rig_t *rig, SerializationContext *ctx,
std::string &activeSection, bool &activeSectionExplicit);
+ int processModules(char *line, rig_t *rig, SerializationContext *ctx,
std::string &activeSection, std::string &previousSection, bool
&activeSectionExplicit);
std::map < std::string, RoRSerializationModule *> sections;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel