Mercurial > hg > orthanc
diff Resources/GenerateErrorCodes.py @ 1585:9a3e03d6a4d5
fix sqlite standalone build
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 25 Aug 2015 19:33:18 +0200 |
parents | bd1889029cbb |
children | 8dc468f44661 |
line wrap: on
line diff
--- a/Resources/GenerateErrorCodes.py Tue Aug 25 17:59:04 2015 +0200 +++ b/Resources/GenerateErrorCodes.py Tue Aug 25 19:33:18 2015 +0200 @@ -111,3 +111,24 @@ with open(path, 'w') as f: f.write(a) + + + +## +## Generate the "ErrorCode" enumeration in "OrthancSQLiteException.h" +## + +path = os.path.join(BASE, 'Core', 'SQLite', 'OrthancSQLiteException.h') +with open(path, 'r') as f: + a = f.read() + +e = filter(lambda x: 'SQLite' in x and x['SQLite'], ERRORS) +s = ',\n'.join(map(lambda x: ' ErrorCode_%s' % x['Name'], e)) +a = re.sub('(enum ErrorCode\s*{)[^}]*?(\s*};)', r'\1\n%s\2' % s, a, re.DOTALL) + +s = '\n\n'.join(map(lambda x: ' case ErrorCode_%s:\n return "%s";' % (x['Name'], x['Description']), e)) +a = re.sub('(EnumerationToString\(ErrorCode.*?\)\s*{\s*switch \([^)]*?\)\s*{)[^}]*?(\s*default:)', + r'\1\n%s\2' % s, a, re.DOTALL) + +with open(path, 'w') as f: + f.write(a)