Mercurial > hg > svcore
comparison data/fileio/TextTest.h @ 1855:db489a1ece9b
Pull out text-document check; it's useful elsewhere
author | Chris Cannam |
---|---|
date | Mon, 11 May 2020 17:27:18 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1854:bde22957545e | 1855:db489a1ece9b |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 | |
8 This program is free software; you can redistribute it and/or | |
9 modify it under the terms of the GNU General Public License as | |
10 published by the Free Software Foundation; either version 2 of the | |
11 License, or (at your option) any later version. See the file | |
12 COPYING included with this distribution for more information. | |
13 */ | |
14 | |
15 #ifndef SV_TEXT_TEST_H | |
16 #define SV_TEXT_TEST_H | |
17 | |
18 #include "data/fileio/FileSource.h" | |
19 | |
20 class TextTest | |
21 { | |
22 public: | |
23 /** | |
24 * Return true if the source appears to point to a text format of | |
25 * some kind (could be CSV, XML, RDF/Turtle etc). | |
26 * | |
27 * We apply two tests and report success if either succeeds: | |
28 * | |
29 * 1. The first few hundred bytes (where present) of the document | |
30 * are valid UTF-8 | |
31 * | |
32 * 2. The document starts with the text "<?xml" when opened using | |
33 * QXmlInputSource (which guesses its text encoding) | |
34 * | |
35 * So we only accept non-UTF-8 encodings where they also happen to | |
36 * be XML documents. | |
37 */ | |
38 static bool isApparentTextDocument(FileSource); | |
39 }; | |
40 | |
41 #endif |