5 inline ostringstream &cendl(ostringstream &os)
11 inline std::ostringstream &dot(std::ostringstream &os)
13 if (os.str().length())
20 inline std::ostringstream &operator<<(std::ostringstream &os, std::ostringstream &(*_Pfn)(std::ostringstream &))
29 using Poco::DirectoryIterator;
32 using Poco::Util::AbstractConfiguration;
33 using Poco::Util::Application;
34 using Poco::Util::HelpFormatter;
35 using Poco::Util::Option;
36 using Poco::Util::OptionCallback;
37 using Poco::Util::OptionSet;
41 class ApiFileOutputStream;
42 class ApiStreamBuffer;
49 explicit tabs(
size_t n)
53 size_t getn()
const {
return _n; }
57 friend std::ostringstream &operator<<(std::ostringstream &os,
const tabs &obj);
58 friend std::ostream &operator<<(ostream &os,
const tabs &obj);
73 poco_assert(indentation > 0);
94 Poco::FileOutputStream stream;
95 ostringstream tempStream;
100 os.tempStream << text;
106 os.tempStream << str;
112 os.tempStream << str;
118 os.tempStream << num;
124 return ((*_Pfn)(os));
129 os.stream << std::endl;
130 os.stream <<
tabs(os.indentation);
131 os.stream << os.tempStream.str();
133 cout << os.tempStream.str() << std::endl;
135 os.tempStream.str(
"");
136 os.tempStream.clear();
142 os.stream << std::endl;
143 os.stream <<
tabs(os.indentation);
144 os.stream << os.tempStream.str();
147 cout << os.tempStream.str() << std::endl;
149 os.tempStream.str(
"");
150 os.tempStream.clear();
166 poco_assert(indentation > 0);
182 os.tempStream <<
".";
186 std::string str() {
return tempStream.str(); }
189 ostringstream tempStream;
194 os.tempStream << text;
200 os.tempStream << str;
206 os.tempStream << str;
212 return ((*_Pfn)(os));
217 os.tempStream << std::endl;
218 os.tempStream <<
tabs(os.indentation);
224 os.tempStream <<
";";
225 os.tempStream << std::endl;
226 os.tempStream <<
tabs(os.indentation);
232 os.tempStream <<
".";
238 size_t n = obj.getn();
239 for (
size_t i = 0; i < n; ++i)
240 os.tempStream <<
"\t";
246 size_t n = obj.getn();
247 for (
size_t i = 0; i < n; ++i)
248 os.tempStream <<
"\t";
252 inline std::ostringstream &operator<<(std::ostringstream &os,
const tabs &obj)
254 size_t n = obj.getn();
255 for (
size_t i = 0; i < n; ++i)
260 inline std::ostream &operator<<(ostream &os,
const tabs &obj)
262 size_t n = obj.getn();
263 for (
size_t i = 0; i < n; ++i)
277 size_t getn()
const {
return _n; }
280 os.tempStream <<
"obj" << obj.getn();
283 friend std::ostringstream &operator<<(std::ostringstream &os,
const temp_name &obj)
285 os <<
"obj" << obj.getn();
303 string getstr()
const {
return _str; }
305 friend std::ostringstream &operator<<(std::ostringstream &os,
const clean_name &obj);
306 template <
class _Traits >
307 friend basic_ostream< char, _Traits > &operator<<(basic_ostream< char, _Traits > &_Ostr,
const clean_name &obj);
312 string newStr = obj.getstr();
315 newStr.erase(std::remove(newStr.begin(), newStr.end(),
':'), newStr.end());
317 os.tempStream << newStr;
320 inline std::ostringstream &operator<<(std::ostringstream &os,
const clean_name &obj)
322 string newStr = obj.getstr();
325 newStr.erase(std::remove(newStr.begin(), newStr.end(),
':'), newStr.end());
331 template <
class _Traits >
332 inline basic_ostream< char, _Traits > &operator<<(basic_ostream< char, _Traits > &_Ostr,
const clean_name &obj)
334 string newStr = obj.getstr();
337 newStr.erase(std::remove(newStr.begin(), newStr.end(),
':'), newStr.end());
352 explicit var_name(
const std::string &str)
360 string getstr()
const {
return _str; }
362 friend std::ostringstream &operator<<(std::ostringstream &os,
const var_name &obj);
363 template <
class _Traits >
364 friend basic_ostream< char, _Traits > &operator<<(basic_ostream< char, _Traits > &_Ostr,
const var_name &obj);
369 string newStr = obj.getstr();
372 newStr.erase(std::remove(newStr.begin(), newStr.end(),
':'), newStr.end());
373 std::transform(newStr.begin(), newStr.begin() + 1, newStr.begin(), ::tolower);
375 os.tempStream << newStr;
379 inline std::ostringstream &operator<<(std::ostringstream &os,
const var_name &obj)
381 string newStr = obj.getstr();
384 newStr.erase(std::remove(newStr.begin(), newStr.end(),
':'), newStr.end());
385 std::transform(newStr.begin(), newStr.begin() + 1, newStr.begin(), ::tolower);
391 template <
class _Traits >
392 inline basic_ostream< char, _Traits > &operator<<(basic_ostream< char, _Traits > &_Ostr,
const var_name &obj)
394 string newStr = obj.getstr();
397 newStr.erase(std::remove(newStr.begin(), newStr.end(),
':'), newStr.end());
398 std::transform(newStr.begin(), newStr.begin() + 1, newStr.begin(), ::tolower);
413 explicit type_name(
const std::string &str)
421 string getstr()
const {
return _str; }
423 friend std::ostringstream &operator<<(std::ostringstream &os,
const type_name &obj);
424 template <
class _Traits >
425 friend basic_ostream< char, _Traits > &operator<<(basic_ostream< char, _Traits > &_Ostr,
const type_name &obj);
430 string newStr = obj.getstr();
433 if (!os.tempStream.str().length())
434 newStr.erase(std::remove(newStr.begin(), newStr.end(),
':'), newStr.end());
435 std::transform(newStr.begin(), newStr.begin() + 1, newStr.begin(), ::toupper);
437 os.tempStream << newStr;
441 inline std::ostringstream &operator<<(std::ostringstream &os,
const type_name &obj)
443 string newStr = obj.getstr();
446 if (!os.str().length())
447 newStr.erase(std::remove(newStr.begin(), newStr.end(),
':'), newStr.end());
448 std::transform(newStr.begin(), newStr.begin() + 1, newStr.begin(), ::toupper);
454 template <
class _Traits >
455 inline basic_ostream< char, _Traits > &operator<<(basic_ostream< char, _Traits > &_Ostr,
const type_name &obj)
457 string newStr = obj.getstr();
461 newStr.erase(std::remove(newStr.begin(), newStr.end(),
':'), newStr.end());
462 std::transform(newStr.begin(), newStr.begin() + 1, newStr.begin(), ::toupper);
473 explicit comment(std::string &str)
477 explicit comment(
const std::string &str)
481 explicit comment(
const char *str)
485 string getstr()
const {
return _str; }
491 string commentStr = obj.getstr();
492 if (commentStr.length())
494 string buffer = commentStr;
495 std::size_t found = buffer.find(
"\n");
496 while (found != std::string::npos)
498 string temp = buffer.substr(0, found);
499 os.tempStream <<
"// ";
500 os.tempStream << temp;
502 if (found + 1 < buffer.length())
504 buffer = buffer.substr(found + 1, buffer.length() - (found + 1));
506 found = buffer.find(
"\n");
510 os.tempStream <<
"// ";
511 os.tempStream << buffer;
540 varNameStream << other.varNameStream.str();
541 typeNameStream << other.typeNameStream.str();
542 prefixStream << other.prefixStream.str();
543 typeStack = other.typeStack;
546 const char *getTypeString(Type type)
548 static const char *TypeString[] = {
"Array",
"Object",
"Map",
""};
549 return TypeString[(Int32)type];
552 void updateStack(
const char *text)
555 for (UInt32 typeIdx = 0; typeIdx < NUM_TYPES; typeIdx++)
557 const char *testString = getTypeString((Type)typeIdx);
558 std::size_t found = str.find(testString);
559 if (found != std::string::npos)
562 tPair.type = (Type)typeIdx;
564 typeStack.push_back(tPair);
578 std::string prefix_str() {
return prefixStream.str(); }
580 std::string var_name_str() {
return varNameStream.str(); }
582 std::string type_name_str() {
return typeNameStream.str(); }
584 std::string debug_str()
586 std::ostringstream tempStream;
587 std::vector< TypePair >::reverse_iterator rit = typeStack.rbegin();
588 tempStream <<
"/*Take 1" << std::endl;
589 for (; rit != typeStack.rend(); ++rit)
591 tempStream <<
"." <<
var_name(rit->name);
593 tempStream << std::endl;
594 for (; rit != typeStack.rend(); ++rit)
598 tempStream << std::endl;
599 tempStream <<
"*/" << std::endl;
600 return typeNameStream.str();
603 std::string debug_str_2()
607 bool arrayMapEncountered =
false;
608 std::vector< TypePair >::reverse_iterator rit = typeStack.rbegin();
609 for (; rit != typeStack.rend(); ++rit)
611 std::vector< TypePair >::reverse_iterator previous = rit + 1;
612 bool previousArrayOrMap =
false;
613 if (previous != typeStack.rend())
615 if (previous->type == ARRAY || previous->type == MAP)
617 previousArrayOrMap =
true;
620 std::ostringstream tempStr;
621 if (arrayMapEncountered)
624 temp = tempStr.str();
626 else if (rit->type == VAR)
629 temp = tempStr.str();
631 else if (rit->type == MAP || rit->type == ARRAY)
633 if (temp.length() && !previousArrayOrMap)
635 tempStr <<
type_name(rit->name) << std::dot << temp;
641 temp = tempStr.str();
642 arrayMapEncountered =
true;
646 if (rit + 1 == typeStack.rend())
648 tempStr <<
var_name(rit->name) << std::dot << temp;
649 temp = tempStr.str();
653 std::ostringstream tempStr;
655 temp = tempStr.str();
659 std::string debug_stack_str()
661 std::ostringstream tempStr;
662 std::vector< TypePair >::iterator it = typeStack.begin();
663 for (; it != typeStack.end(); ++it)
665 tempStr << getTypeString(it->type) <<
".";
667 return tempStr.str();
670 bool wasPreviousPrevious(Type type)
672 if (typeStack.size() > 1)
674 auto &lastType = typeStack[typeStack.size() - 2];
675 return (lastType.type == type ?
true :
false);
680 bool wasPrevious(Type type)
682 if (typeStack.size())
684 auto &lastType = typeStack.back();
685 return (lastType.type == type ?
true :
false);
692 struct special_compare :
public std::unary_function< Type, bool >
694 explicit special_compare(
const Type &baseline)
698 bool operator()(
const TypePair &arg) {
return arg.type == baseline; }
702 std::vector< TypePair >::iterator it = find_if(typeStack.begin(), typeStack.end(), special_compare(type));
703 return (it != typeStack.end() ? true :
false);
706 ostringstream varNameStream;
707 ostringstream typeNameStream;
708 ostringstream prefixStream;
709 vector< TypePair > typeStack;
714 bool previousWasArray =
715 os.wasPrevious(expansionstringstream::ARRAY) || os.wasPrevious(expansionstringstream::MAP);
716 os.updateStack(text);
717 bool newIsObject = os.wasPrevious(expansionstringstream::OBJECT);
718 if (!previousWasArray || !newIsObject)
720 if (!os.varNameStream.str().length())
728 if (!os.typeNameStream.str().length())
734 os.typeNameStream << text;
736 if (!os.prefixStream.str().length())
742 os.prefixStream << std::dot <<
var_name(text);
750 if (os.prefixStream.str().length())
752 os.prefixStream <<
".";
771 os << os.getTypeString(type);
778 return ((*_Pfn)(os));
Definition: fileoutputstream.h:268
Definition: fileoutputstream.h:61
Definition: fileoutputstream.h:154
Definition: fileoutputstream.h:530
Definition: fileoutputstream.h:3
Definition: fileoutputstream.h:518
Definition: fileoutputstream.h:44
Definition: fileoutputstream.h:290
Definition: fileoutputstream.h:404
Definition: fileoutputstream.h:343