Clean up
This commit is contained in:
		
							parent
							
								
									f0351e40de
								
							
						
					
					
						commit
						cdf5271db0
					
				@ -5,12 +5,10 @@ set (HEADERS
 | 
			
		||||
  include/Telegram/PhotoSize.h
 | 
			
		||||
  include/Telegram/User.h
 | 
			
		||||
  include/Telegram/Chat.h
 | 
			
		||||
  include/Telegram/exec.h
 | 
			
		||||
  include/Telegram/Location.h
 | 
			
		||||
  include/Telegram/std.h
 | 
			
		||||
  include/Telegram/Venue.h
 | 
			
		||||
  include/Telegram/Contact.h
 | 
			
		||||
  include/Telegram/explode.h
 | 
			
		||||
  include/Telegram/MessageEntity.h
 | 
			
		||||
  include/Telegram/Sticker.h
 | 
			
		||||
  include/Telegram/Video.h
 | 
			
		||||
@ -27,12 +25,10 @@ set (SOURCES
 | 
			
		||||
  src/PhotoSize.cc
 | 
			
		||||
  src/User.cc
 | 
			
		||||
  src/Chat.cc
 | 
			
		||||
  src/exec.cc
 | 
			
		||||
  src/Location.cc
 | 
			
		||||
  src/std.cc
 | 
			
		||||
  src/Venue.cc
 | 
			
		||||
  src/Contact.cc
 | 
			
		||||
  src/explode.cc
 | 
			
		||||
  src/MessageEntity.cc
 | 
			
		||||
  src/Sticker.cc
 | 
			
		||||
  src/Video.cc
 | 
			
		||||
@ -66,4 +62,3 @@ target_link_libraries(tgbotpp ${LIBS})
 | 
			
		||||
install(TARGETS tgbotpp DESTINATION lib)
 | 
			
		||||
install(FILES ${HEADERS} DESTINATION include/Telegram)
 | 
			
		||||
install(FILES tgbotpp.pc DESTINATION "${INSTALL_PKGCONFIG_DIR}")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,8 +0,0 @@
 | 
			
		||||
#ifndef __EXEC_H__
 | 
			
		||||
#define __EXEC_H__
 | 
			
		||||
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
std::string exec(const char*);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
@ -1,9 +0,0 @@
 | 
			
		||||
#ifndef __explode_h__
 | 
			
		||||
#define __explode_h__
 | 
			
		||||
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
std::vector<std::string> explode( const std::string&, const std::string &);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										21
									
								
								src/exec.cc
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								src/exec.cc
									
									
									
									
									
								
							@ -1,21 +0,0 @@
 | 
			
		||||
#include "Telegram/exec.h"
 | 
			
		||||
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
std::string exec(const char* cmd) {
 | 
			
		||||
 | 
			
		||||
  FILE* pipe = popen(cmd, "r");
 | 
			
		||||
  if (!pipe)
 | 
			
		||||
    return "ERROR";
 | 
			
		||||
 | 
			
		||||
  char buffer[128];
 | 
			
		||||
  std::string result = "";
 | 
			
		||||
  while (!feof(pipe)) {
 | 
			
		||||
    if (fgets(buffer, 128, pipe) != NULL)
 | 
			
		||||
      result += buffer;
 | 
			
		||||
  }
 | 
			
		||||
  pclose(pipe);
 | 
			
		||||
 | 
			
		||||
  return result;
 | 
			
		||||
}
 | 
			
		||||
@ -1,28 +0,0 @@
 | 
			
		||||
#include "Telegram/explode.h"
 | 
			
		||||
 | 
			
		||||
std::vector<std::string> explode( const std::string &delimiter, const std::string &str) {
 | 
			
		||||
 | 
			
		||||
  std::vector<std::string> arr;
 | 
			
		||||
 | 
			
		||||
  int strleng = str.length();
 | 
			
		||||
  int delleng = delimiter.length();
 | 
			
		||||
  if (delleng == 0)
 | 
			
		||||
    return arr;//no change
 | 
			
		||||
 | 
			
		||||
  int i = 0;
 | 
			
		||||
  int k = 0;
 | 
			
		||||
  while(i < strleng) {
 | 
			
		||||
    int j = 0;
 | 
			
		||||
    while ((i+j < strleng) && (j < delleng) && (str[i+j] == delimiter[j]))
 | 
			
		||||
      j++;
 | 
			
		||||
    if (j == delleng) {
 | 
			
		||||
      arr.push_back(str.substr(k, i-k));
 | 
			
		||||
      i += delleng;
 | 
			
		||||
      k = i;
 | 
			
		||||
    } else {
 | 
			
		||||
      i++;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  arr.push_back(str.substr(k, i-k));
 | 
			
		||||
  return arr;
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user