MCPcopy Create free account
hub / github.com/davisking/dlib / get_function_name

Function get_function_name

tools/htmlify/to_xml.cpp:888–956  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

886// ----------------------------------------------------------------------------------------
887
888string get_function_name (
889 const std::vector<std::pair<int,string> >& declaration
890)
891{
892 string name;
893
894 bool contains_operator = false;
895 unsigned long operator_pos = 0;
896 for (unsigned long i = 0; i < declaration.size(); ++i)
897 {
898 if (declaration[i].first == tok_type::KEYWORD &&
899 declaration[i].second == "operator")
900 {
901 contains_operator = true;
902 operator_pos = i;
903 break;
904 }
905 }
906
907
908 // find the opening ( for the function
909 unsigned long paren_pos = 0;
910 long paren_count = 0;
911 for (long i = declaration.size()-1; i >= 0; --i)
912 {
913 if (declaration[i].first == tok_type::OTHER &&
914 declaration[i].second == ")")
915 {
916 ++paren_count;
917 }
918 else if (declaration[i].first == tok_type::OTHER &&
919 declaration[i].second == "(")
920 {
921 --paren_count;
922 if (paren_count == 0)
923 {
924 paren_pos = i;
925 break;
926 }
927 }
928 }
929
930
931 if (contains_operator)
932 {
933 name = declaration[operator_pos].second;
934 for (unsigned long i = operator_pos+1; i < paren_pos; ++i)
935 {
936 if (declaration[i].first == tok_type::IDENTIFIER || declaration[i].first == tok_type::KEYWORD)
937 {
938 name += " ";
939 }
940
941 name += declaration[i].second;
942 }
943 }
944 else
945 {

Callers 2

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected