I would remove the validate method and do some modifications:
About validate methodvalidate:
- Check argc
argcand argvargvoutside the class, just provide the filenamefilenameto the getDatagetDatamethod. - You also need to check when argc
argcis less than 2, the user may forget to supply the filenamefilename. - OpenningOpening the file in the validate method and closing it again does not guarantee that it will be still available when you call getData
getData, so it is better to open the file only there and handle any errors there.
About getDatagetData:
- I would rename it to loadData
loadData. - forFor each line loaded you insert a value in time_ms and text_info vectors, call reserve
reservebefore the loop to pre-allocate the needed memory. - noNo need to call close on the stream, it will close when its scopes end.
validateFileExtentionAbout validateFileExtention:
- use rfindUse
rfindinstead of findfindand just grab the last "." from the string. - I would instead create a function to copy the fileExtension
fileExtensionand check both extensions at once, instead of finding the extension each time. - also I would also not even bother about file extension at all, I. I would just let the parser validate it.
About generateXMLgenerateXML:
- memoryMemory leak: you never delete doc, also. Also, if you need it just inside the method, why you use dynamic memory? Just create it on stack.
- alsoAlso, check if tinyxml deletes everything that you insert on the document, if. If not, you will have to handle this too.
Thats all that I could figure out.
Cheers