mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
make tex2lyx lyxstring agnostic
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7222 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0519b8a2f2
commit
5552f4045f
@ -6,7 +6,6 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "Lsstream.h"
|
||||
#include "tex2lyx.h"
|
||||
|
||||
#include <iostream>
|
||||
@ -15,6 +14,7 @@
|
||||
using std::cerr;
|
||||
using std::endl;
|
||||
using std::ostream;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
|
||||
|
@ -6,11 +6,11 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "Lsstream.h"
|
||||
#include "tex2lyx.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -21,6 +21,7 @@ using std::istream;
|
||||
using std::istringstream;
|
||||
using std::ostream;
|
||||
using std::ostringstream;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
|
||||
|
@ -6,12 +6,12 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "Lsstream.h"
|
||||
#include "tex2lyx.h"
|
||||
|
||||
#include <cctype>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
using std::cerr;
|
||||
@ -19,6 +19,7 @@ using std::endl;
|
||||
using std::istringstream;
|
||||
using std::ostream;
|
||||
using std::ostringstream;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
#include "mathed/math_gridinfo.h"
|
||||
@ -27,7 +28,7 @@ namespace {
|
||||
|
||||
int string2int(string const & s, int deflt = 0)
|
||||
{
|
||||
istringstream is(STRCONV(s));
|
||||
istringstream is(s);
|
||||
int i = deflt;
|
||||
is >> i;
|
||||
return i;
|
||||
@ -51,7 +52,7 @@ string read_hlines(Parser & p)
|
||||
};
|
||||
//cerr << "read_hlines(), read: '" << os.str() << "'\n";
|
||||
//cerr << "read_hlines(), next token: " << p.next_token() << "\n";
|
||||
return STRCONV(os.str());
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
@ -283,7 +284,7 @@ void handle_tabular(Parser & p, ostream & os)
|
||||
ostringstream ss;
|
||||
ss << read_hlines(p) << HLINE; // handle initial hlines
|
||||
parse_table(p, ss, FLAG_END);
|
||||
split(STRCONV(ss.str()), lines, LINE);
|
||||
split(ss.str(), lines, LINE);
|
||||
|
||||
vector< vector<CellInfo> > cellinfo(lines.size());
|
||||
vector<RowInfo> rowinfo(lines.size());
|
||||
|
@ -4,15 +4,13 @@
|
||||
|
||||
// {[(
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "Lsstream.h"
|
||||
#include "tex2lyx.h"
|
||||
|
||||
#include <cctype>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
using std::cout;
|
||||
@ -25,6 +23,7 @@ using std::istringstream;
|
||||
using std::ostream;
|
||||
using std::ostringstream;
|
||||
using std::stringstream;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
|
||||
@ -63,7 +62,7 @@ string const trim(string const & a, char const * p)
|
||||
void split(string const & s, vector<string> & result, char delim)
|
||||
{
|
||||
//cerr << "split 1: '" << s << "'\n";
|
||||
istringstream is(STRCONV(s));
|
||||
istringstream is(s);
|
||||
string t;
|
||||
while (getline(is, t, delim))
|
||||
result.push_back(t);
|
||||
@ -79,7 +78,7 @@ string join(vector<string> const & input, char const * delim)
|
||||
os << delim;
|
||||
os << input[i];
|
||||
}
|
||||
return STRCONV(os.str());
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,11 +24,13 @@ std::string parse_text(Parser & p, unsigned flags, const bool outer);
|
||||
void handle_comment(Parser & p);
|
||||
std::string const trim(std::string const & a, char const * p = " \t\n\r");
|
||||
|
||||
void split(std::string const & s, std::vector<std::string> & result, char delim = ',');
|
||||
std::string join(std::vector<std::string> const & input, char const * delim);
|
||||
void split(std::string const & s, std::vector<std::string> & result,
|
||||
char delim = ',');
|
||||
std::string join(std::vector<std::string> const & input,
|
||||
char const * delim);
|
||||
|
||||
bool is_math_env(std::string const & name);
|
||||
char const ** is_known(string const & str, char const ** what);
|
||||
char const ** is_known(std::string const & str, char const ** what);
|
||||
|
||||
// Access to environment stack
|
||||
extern std::vector<std::string> active_environments;
|
||||
|
@ -2,9 +2,9 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "texparser.h"
|
||||
#include "Lsstream.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
using std::cerr;
|
||||
using std::endl;
|
||||
@ -13,6 +13,7 @@ using std::ios;
|
||||
using std::istream;
|
||||
using std::istringstream;
|
||||
using std::ostream;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
|
||||
@ -126,7 +127,7 @@ Parser::Parser(istream & is)
|
||||
Parser::Parser(string const & s)
|
||||
: lineno_(0), pos_(0)
|
||||
{
|
||||
istringstream is(STRCONV(s));
|
||||
istringstream is(s);
|
||||
tokenize(is);
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
#ifndef PARSER_H
|
||||
#define PARSER_H
|
||||
|
||||
#include "LString.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
enum mode_type {UNDECIDED_MODE, TEXT_MODE, MATH_MODE, MATHTEXT_MODE, TABLE_MODE};
|
||||
|
||||
mode_type asMode(mode_type oldmode, string const & str);
|
||||
mode_type asMode(mode_type oldmode, std::string const & str);
|
||||
|
||||
|
||||
// These are TeX's catcodes
|
||||
@ -62,22 +63,22 @@ public:
|
||||
///
|
||||
Token(char c, CatCode cat) : cs_(), char_(c), cat_(cat) {}
|
||||
///
|
||||
Token(string const & cs) : cs_(cs), char_(0), cat_(catIgnore) {}
|
||||
Token(std::string const & cs) : cs_(cs), char_(0), cat_(catIgnore) {}
|
||||
|
||||
///
|
||||
string const & cs() const { return cs_; }
|
||||
std::string const & cs() const { return cs_; }
|
||||
///
|
||||
CatCode cat() const { return cat_; }
|
||||
///
|
||||
char character() const { return char_; }
|
||||
///
|
||||
string asString() const;
|
||||
std::string asString() const;
|
||||
///
|
||||
string asInput() const;
|
||||
std::string asInput() const;
|
||||
|
||||
private:
|
||||
///
|
||||
string cs_;
|
||||
std::string cs_;
|
||||
///
|
||||
char char_;
|
||||
///
|
||||
@ -97,7 +98,7 @@ public:
|
||||
///
|
||||
Parser(std::istream & is);
|
||||
///
|
||||
Parser(string const & s);
|
||||
Parser(std::string const & s);
|
||||
|
||||
///
|
||||
int lineno() const { return lineno_; }
|
||||
@ -107,13 +108,13 @@ public:
|
||||
void dump() const;
|
||||
|
||||
///
|
||||
string getArg(char left, char right);
|
||||
std::string getArg(char left, char right);
|
||||
/// getArg('[', ']') including the brackets
|
||||
string getOpt();
|
||||
std::string getOpt();
|
||||
///
|
||||
char getChar();
|
||||
///
|
||||
void error(string const & msg);
|
||||
void error(std::string const & msg);
|
||||
///
|
||||
void tokenize(std::istream & is);
|
||||
///
|
||||
@ -129,13 +130,13 @@ public:
|
||||
/// skips spaces if any
|
||||
void skip_spaces();
|
||||
///
|
||||
void lex(string const & s);
|
||||
void lex(std::string const & s);
|
||||
///
|
||||
bool good() const;
|
||||
///
|
||||
string verbatim_item();
|
||||
std::string verbatim_item();
|
||||
///
|
||||
string verbatimOption();
|
||||
std::string verbatimOption();
|
||||
|
||||
///
|
||||
void setCatCode(char c, CatCode cat);
|
||||
@ -151,4 +152,5 @@ public:
|
||||
unsigned pos_;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -6,11 +6,11 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "Lsstream.h"
|
||||
#include "tex2lyx.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
using std::cerr;
|
||||
@ -18,6 +18,7 @@ using std::endl;
|
||||
using std::map;
|
||||
using std::ostream;
|
||||
using std::ostringstream;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
|
||||
@ -596,7 +597,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer)
|
||||
ss << "\\fancyhead";
|
||||
ss << p.getOpt();
|
||||
ss << '{' << p.verbatim_item() << "}\n";
|
||||
handle_ert(os, STRCONV(ss.str()));
|
||||
handle_ert(os, ss.str());
|
||||
}
|
||||
|
||||
else {
|
||||
@ -628,7 +629,7 @@ string parse_text(Parser & p, unsigned flags, const bool outer)
|
||||
{
|
||||
ostringstream os;
|
||||
parse_text(p, os, flags, outer);
|
||||
return STRCONV(os.str());
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user