Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
xtpcpp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PAPPSO
xtpcpp
Commits
97edd298
Commit
97edd298
authored
7 years ago
by
Langella Olivier
Browse files
Options
Downloads
Patches
Plain Diff
mimeparser for mascot
parent
1ec7aea3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/input/mascot/mimeparser.cpp
+80
-0
80 additions, 0 deletions
src/input/mascot/mimeparser.cpp
src/input/mascot/mimeparser.h
+54
-0
54 additions, 0 deletions
src/input/mascot/mimeparser.h
with
134 additions
and
0 deletions
src/input/mascot/mimeparser.cpp
0 → 100644
+
80
−
0
View file @
97edd298
/**
* \file /input/mascot/mimeparser.cpp
* \date 17/2/2018
* \author Olivier Langella
* \brief basic mime multipart parser
*/
/*******************************************************************************
* Copyright (c) 2018 Olivier Langella <olivier.langella@u-psud.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XTPcpp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
******************************************************************************/
#include
"mimeparser.h"
#include
<QRegExp>
MimeParser
::
MimeParser
(
QIODevice
*
p_inputstream
)
{
_p_inputstream
=
p_inputstream
;
}
bool
MimeParser
::
open
()
{
_p_inputstream
->
open
(
QIODevice
::
ReadOnly
);
_real_in
=
new
QTextStream
(
_p_inputstream
);
}
bool
MimeParser
::
close
()
{
if
(
_real_in
!=
nullptr
)
{
delete
_real_in
;
_real_in
=
nullptr
;
}
if
(
_p_inputstream
!=
nullptr
)
{
_p_inputstream
->
close
();
delete
_p_inputstream
;
_p_inputstream
=
nullptr
;
}
}
bool
MimeParser
::
goToFirstFile
()
{
/*
MIME-Version: 1.0 (Generated by Mascot version 1.0)
Content-Type: multipart/mixed; boundary=gc0p4Jq0M2Yt08jU534c0p
--gc0p4Jq0M2Yt08jU534c0p
Content-Type: application/x-Mascot; name="parameters"
*/
QRegExp
regexp_boundary
(
"^Content-Type:
\\
smultipart/mixed;
\\
sboundary=(.*)$"
);
while
(
!
_real_in
->
atEnd
())
{
QString
line
=
_real_in
->
readLine
();
if
(
regexp_boundary
.
exactMatch
(
line
))
{
QStringList
boundary_list
=
regexp_boundary
.
capturedTexts
();
_boundary
=
boundary_list
[
1
];
break
;
}
}
}
bool
MimeParser
::
goToNextFile
()
{
}
const
QString
&
MimeParser
::
getCurrentFileName
()
{
return
_current_file_name
;
}
QTextStream
&
MimeParser
::
getCurrentTextStream
()
{
}
This diff is collapsed.
Click to expand it.
src/input/mascot/mimeparser.h
0 → 100644
+
54
−
0
View file @
97edd298
/**
* \file /input/mascot/mimeparser.h
* \date 17/2/2018
* \author Olivier Langella
* \brief basic mime multipart parser
*/
/*******************************************************************************
* Copyright (c) 2018 Olivier Langella <olivier.langella@u-psud.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XTPcpp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
******************************************************************************/
#ifndef MIMEPARSER_H
#define MIMEPARSER_H
#include
<QIODevice>
#include
<QTextStream>
class
MimeParser
{
public:
MimeParser
(
QIODevice
*
p_inputstream
);
bool
open
();
bool
close
();
bool
goToFirstFile
();
bool
goToNextFile
();
const
QString
&
getCurrentFileName
();
QTextStream
&
getCurrentTextStream
();
private:
QString
_current_file_name
;
QIODevice
*
_p_inputstream
=
nullptr
;
QTextStream
*
_real_in
=
nullptr
;
QString
_boundary
;
};
#endif // MIMEPARSER_H
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment